You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by am...@apache.org on 2003/02/13 08:22:02 UTC
cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/valves ErrorDispatcherValve.java
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: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/valvesErrorDispatcherValve.java
Posted by Glenn Nielsen <gl...@mail.more.net>.
Amy Roh wrote:
> Glenn Nielsen wrote:
>
>>Does this need to be back ported to Tomcat 4?
>
>
> I'll take a look at it and port it if it's necessary. Thanks for the
> reminder. :-)
>
> Amy
I see you ported the patch to Tomcat 4.1. :-)
Thanks,
Glenn
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
Re: cvs commit:
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/valvesErrorDispatcherValve.java
Posted by Amy Roh <am...@apache.org>.
Glenn Nielsen wrote:
>
> Does this need to be back ported to Tomcat 4?
I'll take a look at it and port it if it's necessary. Thanks for the
reminder. :-)
Amy
>
> amyroh@apache.org wrote:
> > 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.
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/valves
ErrorDispatcherValve.java
Posted by Glenn Nielsen <gl...@mail.more.net>.
Does this need to be back ported to Tomcat 4?
amyroh@apache.org wrote:
> 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.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org