Guys,
We are porting a large application from WebLogic 6.1 to WebSphere (v.4,
Windows so far). The architecture is Struts-like and requires the following
flow:
1. POST data to a servlet, incl. an ACTION variable
2. The servlet figures out the so called "filler JSP", which is a non-visual
JSP that fills in a form bean with the posted values using jsp:setProperty
3. The appropriate action class is invoked to save the data using that bean
4. The request is forwarded to the target/next JSP, configured with the
specified ACTION
5. The JSP specifies an error page
This all works well in WebLogic, and the architecture makes a lot of sense
to us. But in WebSphere we get lots of the following:
java.lang.IllegalStateException: ERROR: Cannot forward. Response already
committed.
at
com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestD
ispatcher.java:92)
at
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:498)
at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:599)
at _filler_0002dpage2_jsp_4._jspService(filler-page2.jsp :2)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:142)
. . .
at
com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequest
Dispatcher.java:282)
at
com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestD
ispatcher.java:112)
at
com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppInvoker.java:91)
It looks like the "filler" JSP is already printing to the output. So we
fixed the problem partially by doing "include" instead of "forward" on the
presentation JSP. However, if there is any error on the JSP, we get the
above error in the attempt to forward to the error JSP. And we pretty much
lose the actual exception which occurred on the page and made the servlet
engine try to redirect to the error page.
We have tried to really clean up the "filler" JSP to avoid any whitespace,
but we still get that error. Here is some sample code that illustrates the
problem:
filler-page2.jsp (to handle the POST like a servlet):
<%@ page isErrorPage="false" errorPage="/jsperrhandler.jsp" %>
<jsp:include page="filler-page3.jsp" flush="true"/>
<jsp:forward page="filler-page4.jsp"/>
filler-page3.jsp (the actuall "filler" JSP to capture posted data in a
bean):
<jsp:useBean id="filler" class="Filler" scope="request"/>
<jsp:setProperty name="filler" property="*" />
<%
String[] s = new String[1];
s[0]="filler";
request.setAttribute( "POPULATION", s );
request.setAttribute( "VALIDATION", s );
%>
It seems we cannot forward anymore after page3 was included. Note: WebLogic
is using JSP 1.1 where flush="true" is not required (though default) on
jsp:include. WebSphere is using JSP 1.0 and flush="true" is required!
Any suggestions short of completely re-coding the application architecture
and doing custom exception handling in every page?
Christo
This is your problem. The top level include is flushing the outputstream and
when you try to forward, the exception is thrown.
BTW. Flush is a required attribute and is has to be true for jsp 1.1
(WebSphere 4.0.x).
"Christo Angelov" <cang...@mccrackenfs.com> wrote in message
news:a8t52a$13a0$1...@news.boulder.ibm.com...
"Todd Kaplinger" <kapl...@alum.bentley.edu> wrote in message
news:a8th2l$dv0$1...@news.boulder.ibm.com...
"Christo Angelov" <cang...@mccrackenfs.com> wrote in message
news:a9f1jm$1fh0$1...@news.boulder.ibm.com...
"Christo Angelov" <cang...@mccrackenfs.com> wrote in message
news:a9f1jm$1fh0$1...@news.boulder.ibm.com...