Discussion:
web.xml error-page not working for 500 errors
Jay Wright
2003-02-04 22:05:58 UTC
Permalink
I have configured my webapp to serve up error pages via the web.xml file:

<error-page>
<error-code>500</error-code>
<location>/general_error.html</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/general_error.html</location>
</error-page>

This works without a problem for 404 errors, but 500 errors (such as
NullPointerExceptions) are not redirecting to the general_error.html page.

Is there a reason for this or is it a bug in tomcat 4.0.4?

Jay
Sean Dockery
2003-02-04 23:11:11 UTC
Permalink
I would speculate that the 500 status code is being set inside the default
exception handling code--which probably fall outside the error-page
forwarding mechanism.

Instead of triggering an exception, what happens when you use
HttpSessionResponse.setStatus(500) in a servlet?

I would not consider this to be a bug in Tomcat. How does Resin behave,
for example?

Perhaps a different solution that might work would be to declare the following:

<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/general_error.html</location>
</error-page>

See what that does for you...

At 15:05 2003-02-04, you wrote:

>I have configured my webapp to serve up error pages via the web.xml file:
>
> <error-page>
> <error-code>500</error-code>
> <location>/general_error.html</location>
> </error-page>
> <error-page>
> <error-code>404</error-code>
> <location>/general_error.html</location>
> </error-page>
>
>This works without a problem for 404 errors, but 500 errors (such as
>NullPointerExceptions) are not redirecting to the general_error.html page.
>
>Is there a reason for this or is it a bug in tomcat 4.0.4?
>
>Jay
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-***@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-***@jakarta.apache.org

Sean Dockery
***@sbdconsultants.com
Certified Java Web Component Developer
Certified Delphi Programmer
SBD Consultants
http://www.sbdconsultants.com
Jay Wright
2003-02-05 01:16:48 UTC
Permalink
Thanks Sean!
The <error-page> <exception-type> was EXACTLY what I needed.
Much appreciated.

Jay

> -----Original Message-----
> From: Sean Dockery [mailto:***@sbdconsultants.com]
> Sent: Tuesday, February 04, 2003 3:11 PM
> To: Tomcat Users List
> Subject: Re: web.xml error-page not working for 500 errors
>
>
> I would speculate that the 500 status code is being set
> inside the default
> exception handling code--which probably fall outside the error-page
> forwarding mechanism.
>
> Instead of triggering an exception, what happens when you use
> HttpSessionResponse.setStatus(500) in a servlet?
>
> I would not consider this to be a bug in Tomcat. How does
> Resin behave,
> for example?
>
> Perhaps a different solution that might work would be to
> declare the following:
>
> <error-page>
> <exception-type>java.lang.Exception</exception-type>
> <location>/general_error.html</location>
> </error-page>
>
> See what that does for you...
>
> At 15:05 2003-02-04, you wrote:
>
> >I have configured my webapp to serve up error pages via the
> web.xml file:
> >
> > <error-page>
> > <error-code>500</error-code>
> > <location>/general_error.html</location>
> > </error-page>
> > <error-page>
> > <error-code>404</error-code>
> > <location>/general_error.html</location>
> > </error-page>
> >
> >This works without a problem for 404 errors, but 500 errors (such as
> >NullPointerExceptions) are not redirecting to the
> general_error.html page.
> >
> >Is there a reason for this or is it a bug in tomcat 4.0.4?
> >
> >Jay
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tomcat-user-***@jakarta.apache.org
> >For additional commands, e-mail: tomcat-user-***@jakarta.apache.org
>
> Sean Dockery
> ***@sbdconsultants.com
> Certified Java Web Component Developer
> Certified Delphi Programmer
> SBD Consultants
> http://www.sbdconsultants.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-***@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-***@jakarta.apache.org
>
Loading...