tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kief Morris <>
Subject Re: Custom error pages!!
Date Tue, 12 Dec 2000 11:26:28 GMT
Pankaj Bhagat typed the following on 11:58 12/12/2000 +0100
>So now what i can understand is that it should be Tomcat's problem to
>intercept any errors occuring in the servlet and then passing me onto the
>specified url in the deployment descriptor.

I believe this only applies to JSP pages. For your servlet, you should just
catch it normally:

public void doGet (...)
    try {
        // your code here
    } catch (Throwable e) {
        // forward to an error page
    // write headers and output

If you want to take advantage of JSP error page handling, a slick thing to do 
might be to insert the Throwable object into the request as an attribute 
named "javax.servlet.jsp.jspException", then forward to a JSP page whose 
page directive includes the parameter isErrorPage="true". This will automatically
create a variable called "exception" in the error page, which will be a reference
to the Throwable object you set in the request.

Check out section 2.7.1 of the JSP specification document for details on how
this works.


              bitBull makes the Internet bite:

View raw message