Why do I get the error “IllegalStateException” when using the RequestDispatcher?
Location: http://www.jguru.com/faq/view.jsp?EID=501393 Created: Sep 21, 2001 Author: Alex Chaffee (http://www.jguru.com/guru/viewbio.jsp?EID=3) Question originally posed by Mark Gorenstein (http://www.jguru.com/guru/viewbio.jsp?EID=492823 When you use RequestDispatcher.forward or RequestDispatcher.include to call another servlet, you must pay very close attention to a fairly tricky detail of the servlet “chain of command.” When a servlet is first called, the response object is fresh and new: its headers have not been set, its buffers are empty, and no data has been written to the client. However, as soon as either the status code or any of the headers have been written — or potentially written — to the client, or when data has been — or may have been — written to the body stream, then you may be susceptible to the IllegalStateException error. The problem that this exception is signalling is the new data that you are (or may be) writing is inconsistent with the data that’s already b