I have a web application that shows a series of pages - each one containing a set of images. JSF commandButtons and actions are used to navigate between the pages. The images are generated by a Servlet, and take a while (hundreds of ms each) to generate and download.

If a page is submitted before all the images are downloaded, more often than not, a blank response is displayed and an IllegalStateException / ServletException (depending on whether Tomcat 5.5 or 5.0 is being used) is thrown with the message:

"Cannot forward after response has been committed."

The problem is made worse by a slow server, a fast connection to the server, and if the JSF page and images take a long time to generate.

Unfortunately, this makes the application unusable :-(.

I have created a JIRA entry for this bug, and give a simplified test case that demonstrates the problem (a single page containing a no-op commandButton and a graphicImage linked to a "SlowServlet"):

http://issues.apache.org/jira/browse/MYFACES-612

Has anyone else seen this problem? Does anyone have any ideas about how to work around it? How might I work out how to fix MyFaces?

As the stack traces in the JIRA entry show, the exception is thrown when the ViewHandler tries to dispatch the request to the JSP page to render the response. Perhaps something in MyFaces is flushing the FacesServlet output buffer prematurely? The size of the page in the test case is well below the 8k standard buffer size, but my understanding is that nothing should be written to the output buffer before the dispatch to the JSP page.

Jeremy

Reply via email to