You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Daniel Collins <Da...@tertio.com> on 2002/07/10 16:35:37 UTC

custom error-pages




I was playing around with creating some custom error pages for a web application
(servlets and JSPs) and I'm not sure if what I am seeing is correct or not. I've
had a look around the archives but can't see anything about this particular
problem, but apologies if someone's already asked it (or I'm missing something
blindinly obvious!)

The application occasionally throws ClassCastExceptions in the JSPs (in essence
jsp:useBean finds a bean of the same name but wrong class and tries to cast it
unsuccessfully) which generate Error 500: Internal Servlet Errors, so I added
the following to my web.xml:

  <error-page>
    <error-code>500</error-code>
    <location>/errors/test.html</location>
  </error-page>

But it didn't work, it still gave me Tomcat's default error page. (And yes that
html file does exist relative to the web-root).

I then trapped the exception directly with the following:

  <error-page>
    <exception-type>java.lang.ClassCastException</exception-type>
    <location>/errors/test2.html</location>
  </error-page>

And it goes to the correct error page, why does the exception trapping work but
the error code not? (Yes they are different error pages, but it's just so I can
see which one is being produced for now).  I've tried this in both 3.3.1 and
4.0.4 with the same results, which implies to me that it's something in my
expectation that is wrong rather than tomcat.

Thanks,

Daniel


 Tertio Telecoms Limited  -  One Angel Square,   Torrens Street,   London  EC1V
1PL
Tel: +44 (0)20 7843 4000 Fax: +44 (0)20 7843 4001 Web http://www.tertio.com
Any views expressed in this message are those of the individual sender,
except where the sender specifically states them to be the views of Tertio Ltd.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: custom error-pages

Posted by Ricky Leung <ri...@booksense.com>.
I asked about this before but it is according to spec so I did this instead.

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

This is basically the same as a 500 with any type of exception catched and
presented with a better formatted page.



> -----Original Message-----
> From: Daniel Collins [mailto:Daniel_Collins@tertio.com]
> Sent: Wednesday, July 10, 2002 10:36 AM
> To: tomcat-user@jakarta.apache.org
> Subject: custom error-pages
>
>
>
>
>
>
> I was playing around with creating some custom error pages for a
> web application
> (servlets and JSPs) and I'm not sure if what I am seeing is
> correct or not. I've
> had a look around the archives but can't see anything about this
> particular
> problem, but apologies if someone's already asked it (or I'm
> missing something
> blindinly obvious!)
>
> The application occasionally throws ClassCastExceptions in the
> JSPs (in essence
> jsp:useBean finds a bean of the same name but wrong class and
> tries to cast it
> unsuccessfully) which generate Error 500: Internal Servlet
> Errors, so I added
> the following to my web.xml:
>
>   <error-page>
>     <error-code>500</error-code>
>     <location>/errors/test.html</location>
>   </error-page>
>
> But it didn't work, it still gave me Tomcat's default error page.
> (And yes that
> html file does exist relative to the web-root).
>
> I then trapped the exception directly with the following:
>
>   <error-page>
>     <exception-type>java.lang.ClassCastException</exception-type>
>     <location>/errors/test2.html</location>
>   </error-page>
>
> And it goes to the correct error page, why does the exception
> trapping work but
> the error code not? (Yes they are different error pages, but it's
> just so I can
> see which one is being produced for now).  I've tried this in
> both 3.3.1 and
> 4.0.4 with the same results, which implies to me that it's something in my
> expectation that is wrong rather than tomcat.
>
> Thanks,
>
> Daniel
>
>
>  Tertio Telecoms Limited  -  One Angel Square,   Torrens Street,
>  London  EC1V
> 1PL
> Tel: +44 (0)20 7843 4000 Fax: +44 (0)20 7843 4001 Web
http://www.tertio.com
Any views expressed in this message are those of the individual sender,
except where the sender specifically states them to be the views of Tertio
Ltd.



--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>