Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting java.lang.IllegalStateException error with response.getOutputStream

843841Mar 3 2005 — edited May 28 2008
Hi,

I am writer a JSP site for displaying JFreeChart. The main JSP page gets some parameters then the second page out put the chart as binary data with a Java class.

I've located the part which generated the error, as follows:

Code:
OutputStream os = response.getOutputStream(); <--- this line cause the error
response.setContentType("image/png");
ChartUtilities.writeChartAsPNG(os, chart, 400, 300);

(other than it, the JSP does nothing with response or out)

Error:
Servlet.service().for servlet jsp threw exception java.lang.IllegalStateException
at org.apache.jasper.runtime.ServletResponseWrapperInclude.getOutputStream(ServletResponseWrapperInclude.java:62)
at org.apache.jsp.build005f005.seriesChart_jsp.jspService(org.apache.jsp.build_005f005.seriesChart_jsp:110)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWarpper.java:325)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
.....

I've searched this forum and google and seeking for solution for thousands times. But sadly, ways such as adding out.reset(); doesn't work.
Would any one has some suggestion for me? Your help is very appreciated. Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 25 2008
Added on Mar 3 2005
20 comments
6,439 views