tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Maurice Marrink" <>
Subject custom error pages
Date Thu, 05 Aug 2004 07:53:09 GMT

I,m using tomcat 5.0.27 and am trying to show custom error pages.
I added a couple of errorpage tags to my webapps web.xml and the
/conf/web.xml in the tomcat installation dir.
and after telling internet explorer not to use userfriendly errorpages it
shows the errorpages defined in my webapp when I try to access an
nonexisting url inside my webapps context (e.g.
/my_existing_webapp/does_not_exist.html) and shows the default errorpages
when I go to an url that does not exist at all (e.g.
/non_existing_webapp/whatever.html), that is after I copied my error files
into the ROOT context.
But I cant get it to work when my webapp is defined but not running. What I
did was this:
- start tomcat
- goto the manager webapp
- shutdown the webapp with custom errorpages
- enter a valid url for that webapp in the browser.

Now I get the standard tomcat errorpage.
So I did a little debugging and found that when tomcat stops a webapp, it
preserves the context it just strips it from all but the name (well almost).
So my custom defined errorpages are gone and because tomcat did find a
context it wont use the errorpages defined in the default web.xml (or root
context) but instead goes for the tomcat errorpage.

I thought I could outsmart tomcat, so I made a little lifecylelistener and
container listener so I would get notified of the removal of my errorpages
and then put them back in. Even though that works, tomcat still shows its
own errorpages because further down the line it tries to get a
requestdispatcher from the context (which was stripped) to forward the
request for the errorpages. And there it fails offcourse.

Now we get to the question(s) :)

- does anyone know what else needs to be preserved in the context in order
to deliver a valid requestdispatcher (there is a lot that gets removed, and
its probably quicker to get an answer from you guys then painstakingly use
trial and error)
- or perhaps a better question could you guys (developers) make the next
(nightly) release so that it tries to get errorpages from the default
web.xml (root context) before showing the tomcat errorpage. Because its more
then likely my little hack is going to break something if I get it to work.

If no one can or bothers to answer the first question I can live with that,
I've surrendered :) but I would like to see the 2nd request/ feature to


Maurice Marrink

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message