On Tue, May 24, 2011 at 9:59 AM, Sai Pullabhotla <
sai.pullabho...@jmethods.com> wrote:

> I've a web application with two contexts "ROOT" and "mycontext". Both
> contexts have custom error pages defined in the web.xml and everything
> works as expected in most cases. The only problem is that if my
> context, mycontext, fails to initialize (e.g. database is
> unavailable), and if some one tries to access a page from context1,
> Tomcat falls back to the default error pages. Is there a way to
> override the default error pages in this case?
>
> If the application throws an exception during context initialization, then
the web app is not loaded. Hence your custom error pages won't be defined.
The logical choice would be to stop the app from failing during context
initialization - well at least stop it from throwing an exception. Then the
app would still load into tomcat, and so the custom pages would still work.
Can you perform the initialization using lazy instantiation?

I guess the question is what do you want to happen when db fails during
context initialization? You could have a flag and a filter that redirects to
a "all broken" jsp if the app can't connect to the db?

HTH

Chris

Reply via email to