Rot Error -1: ERROR: Cannot forward. Writer or Stream already obtained.
java.lang.IllegalStateException: ERROR: Cannot forward. Writer or Stream
already obtained.
at java.lang.RuntimeException.<init>(RuntimeException.java:49)
at
java.lang.IllegalStateException.<init>(IllegalStateException.java:47)
at
com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleOutputStreamPrin
terWriterObtained(WebAppRequestDispatcher.java:595)
at
com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestD
ispatcher.java:112)
at MyServlet.performTask(MyServlet.java:120)
at MyServlet.doGet(MyServlet.java:27)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
..........
The processing flow of the http request is:
request from browser -> main servlet -> forward to a generic
jsp -> include another servlet -> forward to final jsp
The error message occurred when the last servlet tries to forward to the
final jsp.
I wonder why it is okay with version 3.5 but failed with 3.5.4.
Sincerely,
Catherine
"Catherine" <li...@arkayusa.com> wrote in message
news:9oaq6v$usi$1...@news.boulder.ibm.com...
Alex.
The point is, I did not call the getWriter() method at all. What I did are:
1) In the main servlet:
1a) setContentType, setHeader;
1b)
getServletConfig().getServletContext().getRequestDispatcher("result.jsp").fo
rward(request, response);
2) In the result.jsp, there are a fixed header and footer, and:
<jsp:include page="SecondServlet" />
3) In SecondServlet:
getServletConfig().getServletContext().getRequestDispatcher("response.jsp").
forward(request, response);
I did not write any response in the servlets. All response html were written
by jsp.
No getWriter() issued, no flush buffer performed.
Is there anything wrong with my processing sequence described above?
"Alex Matthews" <al...@xelacom.com> wrote in message
news:3BA8EFAD...@xelacom.com...
setContentType (and possibly setHeader) write back to the output stream.
See section 5.5 of the servlet 2.2 spec - it's not limited to getWriter.
I'm also not sure you can invoke forward from an included servlet.
Alex.
Ken
Eric
Alex.
Cheers,
Catherine
"Alex Matthews" <al...@xelacom.com> wrote in message
news:3BA9E37A...@xelacom.com...