Hi All, Have been breaking my head on this one for more than a week now and just can't get it to work. Even with the most simple files below. Have spent many hours on the internet searching for answers and know that this issue has been posted many times before. Though all posts that I found dealt with this exception getting thrown out of man made servlets and not out of jsp-pages.
Tomcat 5.5.15 on Windows XP (jdk 1.5.0_04) Would like to redirect 404 - "Page Not Found" errors to my own 404.jsp page, but is not working. On the client I get to see the standard Tomcat 404 screen and in the log I'm getting the dreadful "java.lang.IllegalStateException: getOutputStream() has already been called for this response" The exception is thrown out of the Tomcat generated _404_jsp.java file on its last line: if(_jspxFactory!=null) _jspxFactory.releasePageContext(_jspx_page_context); I read over and over again that this has to do with the response.getOutputStream() getting called multiple times and what more about response.getWriter(). The thing is that I don't have any java code yet in my jsp-file so am not calling any of that. Everything is auto generated by Tomcat. When I replace my 404.jps with a simple 404.html file and make the change in web.xml, then the 404.html is displayed on the client as expected. I have a few other jsp-pages that do have java code and if an exception is thrown out of those pages, then UnhandledExceptions.jsp is called and displayed on the client as expected. The strange thing from reading the logs, is that it looks like the 404.jsp is getting called multiple times in case of an actual 404 error: 1. during the first pass, the 404.jsp is processed as expected (as far as I can tell); 2. during a second pass, I see the getOutputStream() already been called on org.apache.catalina.core.ApplicationDispatcher invoke 3. during a third pass, I see the getOutputStream() already been called on org.apache.catalina.core.StandardHostValve custom And after that the standard Tomcat 404 appears on the client. Anyone any ideas? Web.xml ------- .. <error-page> <error-code>404</error-code> <location>/errpages/404.jsp</location> </error-page> <error-page> <exception-type>java.lang.Throwable</exception-type> <location>/errpages/UnhandledExceptions.jsp</location> </error-page> 404.jsp ------- <table> <tr><td>Page not found!</td></tr> </table> UnhandledExceptions.jsp ----------------------- <%@ page isErrorPage="true" %> <jsp:include page='/somepage.jsp' /> <table> <tr><td>BooBoo occurred!</td></tr> <tr><td><%= exception.getMessage() %></td></tr> </table> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]