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:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to