I created a little test servlet to test includes and forwards in a clean
environment.
The following block was used to test include/response within a servlet:
(nothing is "written" to the output buffer before the forward | includes)
<snip>
//response.getWriter().write("test");
dispatcher.forward(request, response);
// dispatcher.include(request, response);
// dispatcher.include(request, response);
//response.getWriter().write("test");
</snip>
1) Running with forward uncommented:
I now get a different error, for the first time! --
java.net.SocketException: Socket Closed
The chart displays fine in the browser.
2) Running with one or two includes uncommented:
I get java.lang.IlligalStateExeption: getOutputStream() has already
been called for this response.
I get garbage in the browser
3) Running with the top write, and forwards uncommented:
The chart is displayed properly, AND I get a message box saying
that the document contained no data!
I get java.lang.IlligalStateException: getWriter() has already been
called.
I am "beginning" to think that this is expected behavior according to
servlet specs (which I d/loaded and promissed myself I'd read.... :)
Even if this is the case, there must be a way to include charts, or
combination of charts, and other stuff on the same page...it's not like
it's never been done before...
Regards!
Dmitry
KC Berg wrote:
>How are you doing the includes? Also when you are using a forward in a
>servlet you can not print anything to the output buffer before you use the
>forward. Because once the output stream has been sent to the browser the
>server can no longer forward that stream to another servlet.
>
>KC
>
>-----Original Message-----
>From: Dmitry Nikelshpur [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, February 26, 2002 12:40 PM
>To: [EMAIL PROTECTED]
>Subject: IlligalStateException -- getOutputStream() has already been
>called for this response.
>
>
>Hello everyone.
>
>I had posted a similar message before, but either did not get replies or
>missed them.
>
>I am using a JavaBean in a JSP page. This bean draws charts and graphs
>depending on supplied data...
>
>When I call the JSP page directly from the browser, the graph displays
>properly, and no error messages are dumped to catalina.out.
>
>When I have a servlet forward to the JSP page, the graphs display
>properly, but I get a message in catalina.out:
>java.lang.IlligalStateException: getOutputStream() has already been
>called for this response.
>
>When I have a servlet include the JSP page, I get garbage in the
>browser, and the same message in catalina.out,
>java.lang.IlligalStateException: getOutputStream() has already been
>called for this response.
>
>I had seen posts regarding this error, and believe that I saw something
>in the bug databasee, but still no solution.
>Is this behavior 'normal?' for JSPs / Servlets?
>
>The bean that I am using to create the charts is called jspChart, and is
>at: http://www.javaside.com/u_jspchart.html
>This URL contains a sample JSP page, so any servlet that includes /
>forwards this page should produce above results.
>
>I would apprecieate it if you could BCC me in your replies, to make sure
>I get the message.
>Also, if you have any other solutions for creating charts/graphs
>dynamically, with the ability to include/forweard from servlets, I'll be
>more than pleased...
>
>Thanks in advance!
>
>
>Dmitry
>
>
>
>--
>To unsubscribe: <mailto:[EMAIL PROTECTED]>
>For additional commands: <mailto:[EMAIL PROTECTED]>
>Troubles with the list: <mailto:[EMAIL PROTECTED]>
>
>--
>To unsubscribe: <mailto:[EMAIL PROTECTED]>
>For additional commands: <mailto:[EMAIL PROTECTED]>
>Troubles with the list: <mailto:[EMAIL PROTECTED]>
>
>
>
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>