[jboss-user] [Tomcat, HTTPD, Servlets & JSP] - IllegalStateException: getOutputStream() has already been ca

sirji do-not-reply at jboss.com
Tue May 22 16:59:05 EDT 2007


Hi all,

I know many of you after reading the subject would be thinking of suggesting few changes like "don't you use getOutputStream() in JSP or use PrintWriter's getWriter instead". But I have tried most of the suggestions/pointers available in other forums.

Problem is that it is *must* for us to use response's OutputStream object as we have to invoke a 3rd Party library API that *only* takes OutputStream object.

Now, my concern is how can we stop JBoss calling releasePageContext during JSP lifecycle. As this also calls getOutputStream() which seems to be cause of the problem.

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

Please correct me if wrong. Below is the error snippet.




  | 02:09:54,045 ERROR [[action]] Servlet.service() for servlet action threw exception
  | java.lang.IllegalStateException: getOutputStream() has already been called for this response
  |         at org.apache.catalina.connector.Response.getWriter(Response.java:599)
  |         at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:195)
  |         at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:111)
  |         at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:124)
  |         at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:117)
  |         at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:182)
  |         at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:115)
  |         at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:75)
  |         at org.apache.jsp.ui.rawReport_jsp._jspService(rawReport_jsp.java:873)
  |         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
  |         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)

Thanks and regards,

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4047715#4047715

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4047715



More information about the jboss-user mailing list