amyroh 2003/02/12 23:22:01 Modified: catalina/src/share/org/apache/catalina/valves ErrorDispatcherValve.java Log: Fix to return an error-page for 500 if it's defined in web.xml. If ErrorDispatcherValve does not find an error-page for an internal error, it sets the error code to 500 but does not then try to see if there is an error-page mapping for this error code. If the servlet throws an exception that does not map to an error-page, then we should set the error-code to 500 and see if there is an error-page for 500 and if so, return that. Most users will configure a generic error-page for 500 rather than for exception-types. Fix for bugtraq 4685997. Revision Changes Path 1.5 +27 -6 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/valves/ErrorDispatcherValve.java Index: ErrorDispatcherValve.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/valves/ErrorDispatcherValve.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ErrorDispatcherValve.java 4 Nov 2002 06:33:02 -0000 1.4 +++ ErrorDispatcherValve.java 13 Feb 2003 07:22:01 -0000 1.5 @@ -258,7 +258,22 @@ log("Exception Processing " + errorPage, e); } } + } else { + // A custom error-page has not been defined for the exception + // that was thrown during request processing. Check if an + // error-page for error code 500 was specified and if so, + // send that page back as the response. + ServletResponse sresp = (ServletResponse) response; + if (sresp instanceof HttpServletResponse) { + ((HttpServletResponse) sresp).setStatus( + HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + // The response is an error + response.setError(); + + status(request, response); + } } + } @@ -389,7 +404,14 @@ try { // Reset the response if possible (else IllegalStateException) - hres.reset(); + //hres.reset(); + // Reset the response (keeping the real error code and message) + Integer statusCodeObj = + (Integer) hreq.getAttribute(Globals.STATUS_CODE_ATTR); + int statusCode = statusCodeObj.intValue(); + String message = + (String) hreq.getAttribute(Globals.ERROR_MESSAGE_ATTR); + ((HttpResponse) response).reset(statusCode, message); // Forward control to the specified location ServletContext servletContext = @@ -451,4 +473,3 @@ } -
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]