At 12:54 PM 6/16/2004, Bob Thomas wrote:
Here's the stack trace:

java.lang.IllegalStateException: Cannot forward after response has been committed
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:371)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:359)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)

My guess is that you are using the ServletContext's request dispatcher to forward the request after the response has been committed by the RequestProcessor. That is a "no-no".


Are you using Tomcat 5?  If so, then, if you have code like this:


if (something) { forward("/somewhere", req, res); } else { // do this }

public void forward(String url, HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException {
RequestDispatcher rd = req.getRequestDispatcher(url);
rd.forward(req, res);
}


You need to use code like this:


if (something) { forward("/somewhere", req, res); return; } else { // do this } // continue on with the page

At any rate, you should always include a return in these circumstances.





Reply via email to