View Full Version : accessing report by JSP getting exception

12-18-2009, 07:29 AM
I developed one report in which i passed date from my JSP it working fine if Database having some data on respective date ....if in particular date if database not having any data then my jsp showing Exception
In Report designer its showing blank report ......I wanted same thing on my JSP .

Exception is

java.lang.IllegalStateException: getOutputStream() has already been called for this response org.apache.catalina.connector.Response.getWriter(Response.java:607) org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:196) org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:125) org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:118) org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:179) org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:116) org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:76) org.apache.jsp.global_005ftab_005fdata_jsp._jspService(org.apache.jsp.global_005ftab_005fdata_jsp:172) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) I am just calling my PRPT file HtmlReportUtil.createStreamHTML(report,response.getOutputStream());Can any body suggest whats issue and how to solveThanks in Advance

12-18-2009, 07:55 AM
getOutputStream() has already been called for this response

You cannot call ServletResponse#getOutputStream() twice. In JSPs this is already called by the JSP itself and should be availble as extra variable (heck, it has been ages since I worked with JSPs, check the Servlet/JSP-Standard for where it is stored).

Unless your report produces HTML, it is also generally a bad idea to combine reporting engine output and HTML output from the JSP. Usually it is better to use a Servlet to handle requests that may produce binary data (as reports usually do).

12-19-2009, 03:33 PM
Hi Taqua,
We knew that you can't call twice #getoutputstream on response object. But what really surpises me that this is happening only when the reports query has no rows in its result. When it has rows in its results, this error doesn't come.
Won't be it advisible to add another overloaded method HtmlReportUtil.createStreamHTML(report, PrintWriter out) like in previous versions. Here we could pass implicit JSP printwriter out object?

12-21-2009, 08:37 AM
Hi Taqua,
I am facing same problem with servlet also.

If database having no data on corresponding date then it gives same exception


12-21-2009, 10:03 AM
Well, I currently cannot access your harddisk. So I cant see your code and also cannot see the exceptions you get. Once the CIA approved my support desk status and allows me full access to other persons computers, I probably have more luck. But most of the people at the headquarter are already on vacation, so this wont happen this year.

Of course, you could alternatively provide more details on what you are doing and what exactly the exception is that you are getting. And version numbers help too.