`
dushanggaolou
  • 浏览: 172961 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

java.lang.IllegalStateException: getOutputStream() has already been called for t

    博客分类:
  • jbpm
 
阅读更多

严重: Servlet.service() for servlet jsp threw exception

java.lang.IllegalStateException: getOutputStream() has already been called for this response

 

at org.apache.catalina.connector.Response.getWriter(Response.java:610)

at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)

at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:125)

at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:118)

at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:188)

at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:118)

at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:77)

at org.apache.jsp.pic_jsp._jspService(pic_jsp.java:88)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)

 

 

 

问题分析:前台程序可以正常运行,但是当查看流程进行到哪一步的时候,控制台就报这个错误。

              具体的原因就是在tomcat中jsp编译成servlet之后在函数

_jspService(HttpServletRequest request, HttpServletResponse response)

 

                  的最后有一段这样的代码

finally {

       if (_jspxFactory != null) {            
             _jspxFactory.releasePageContext(_jspx_page_context);
        }
     }

 

              这里是在释放在jsp中使用的对象,会调用response.getWriter(),因为这个方法是和
              response.getOutputStream()相冲突的!所以会出现以上这个异常。

 

解决方法:

              在使用完输出流以后调用以下两行代码即可:

out.clear();
out = pageContext.pushBody();

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics