在写JSP程序的时候,如果程序中调用了response.getOutputStream()去向客户端输出文件等数据流,容器就会抛出这样的异常:
Java.lang.IllegalStateException: getOutputStream() has already been called for this response at org.apache.catalina.connector.Response.getWriter(Response.java:596)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:186)
产生这样的异常原因:是web容器生成的servlet代码中有out.write(""),这个和JSP中调用的response.getOutputStream()产生冲突.即Servlet规范说明,不能既调用response.getOutputStream(),又调用response.getWriter(),无论先调用哪一个,在调用第二个时候应会抛出IllegalStateException,因为在jsp中,out变量实际上是通过response.getWriter得到的,你的程序中既用了response.getOutputStream,又用了out变量,故出现以上错误。
解决方案:
在程序的最后添加以下代码即可:
out.clear();
out = pageContext.pushBody();
就可以了.
分享到:
相关推荐
纠结了半天的 java.lang.IllegalStateException: getOutputStream() has already。这个问题困扰了半天,在网上查阅了大量资料 出这个错误一般就是下面2个.....
IllegalStateException: The specified child already has a parent.我的博客中有文章讲解
NULL 博文链接:https://hw1287789687.iteye.com/blog/1925191
异常:Caused by: java.lang.IllegalStateException: Method has too many Body parameters Caused by: java.lang.IllegalStateException: Method has too many Body parameters: public abstract ...
1. java.lang.IllegalStateException: No wrapped connection. 2.java.lang.IllegalStateException: Adapter is detached. 原因: 1.单线程一次执行一个请求可以正常执行,如果使用多线程,同时执行多个请求时就会...
解决java.lang.IllegalStateException: unread block data的架包
java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but...
NULL 博文链接:https://anminer.iteye.com/blog/845067
spring 总的概述。。。入门好教程~~~~~~~~~~~~~
您可以在的非常权威的阅读有关该问题和可能的解决方案的更多信息。 主意 为了避免异常,不应在 Activity 处于非可见(活动)状态时进行转换。 这可以通过简单地缓冲发送到 UI 的操作来实现,直到 UI 能够处理它们。...
各种数据库在JDBC中的连接方法.及在struts与hibernate中的配置..
因工作的缘故,有机会接触了Java本地方法调用(JNI)。本文中记下了初试JNI的过程和一点点体会。 使用Java的JNI调用C/C++的动态联结库有个固定的步骤,下面将以一个最简单的HelloWorld例子程序来说明调用过程。...
今天公司springboot项目准备部署到...java.lang.IllegalStateException: 启动子级时出错 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:720) at org.apache.catalina.core.Con
SteganoImage 1.0 绿色版
里面包含了java通过xfire访问webservice用到的jar包,已经打包好了
主要介绍了java 实现websocket的两种方式实例详解,一种使用tomcat的websocket实现,一种使用spring的websocket,本文通过代码给大家介绍的非常详细,需要的朋友可以参考下
Jnative1.4_java调用动态库所需jar,里面包含了一个可以测试的动态库,可以自己拿下来玩玩。
java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate....
ssh整合的时候 启动tomcat常见的错误
oop object c, for apple ios developer