Thought if I include the code it might help a little:
Piece of code in the calling servlet:
..............
..............
in = new BufferedReader(new InputStreamReader(uconn.getInputStream
()));
resp.setContentType("text/html");
System.err.println("About to read and output content using
PrintStream....");
String line;
PrintStream pw = new PrintStream(resp.getOutputStream(), true);
while((line = in.readLine()) != null)
{
pw.println(line);
pw.flush();
System.err.println("Flushed data back....");
}
pw.flush();
in.close();
..............
..............
where,
uconn is the URLConnection to the called servlet.
Maybe I should buffer the output before I send it across to the browser.
Still waiting :-)
Thanks.
(Embedded image moved to file: pic04041.pcx)
Roshan A. Sequeira
(Embedded image moved to file: pic03602.pcx)
12/13/2001 11:57 AM
To: "Tomcat Users List" <[EMAIL PROTECTED]>
cc:
Subject: java.lang.IllegalStateException
I'm calling a servlet from within another servlet using the URL class. The
calling servlet posts data, reads the output, and then passes on the
output to the browser. In JRun everything works fine. But on Tomcat
the same throws a java.lang.IllegalStateException
Error:
java.lang.IllegalStateException: Writer is already being used for this
request
at
org.apache.tomcat.facade.HttpServletResponseFacade.getOutputStream(HttpServletResponseFacade.java:158)
I'm using a PrintWriter (which I get from the response object) in the
called servlet. And I've a finally block which closes the stream. Also
assign the object to null.
The calling servlet which behaves like a proxy has a PrintStream (which it
gets from it's response object). This object is used to write the output
(that it reads from the called servlet) to the browser.
I know I'm missing something fundamental here. But can't seem to figure it
out. Is Tomcat getting mixed up with two Outputstreams/Writers? Any
ideas/comments?
Thanks.
RS
pic04041.pcx
Description: Binary data
pic03602.pcx
Description: Binary data
-- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>
