tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: Overriding error page displayed when a context fails to initialize
Date Tue, 24 May 2011 18:15:03 GMT
Caldarale, Charles R wrote:
>> From: Sai Pullabhotla [mailto:sai.pullabhotla@jmethods.com] 
>> Subject: Re: Overriding error page displayed when a context fails to initialize
> 
>> What I'm looking for is a way to override the error pages of 
>> Tomcat at the global level (not application/context specific)
> 
> There's no such mechanism mostly because the servlet spec doesn't provide for one.  The
ROOT webapp becomes the catch-all, and you can put filters and generic error pages there.
> 

Would the following work, e.g. ?

Suppose there are 3 webapps : app1, app2, app3,
respectively deployed at
(tomcat_dir)/webapps/app1
(tomcat_dir)/webapps/app2
(tomcat_dir)/webapps/app3

plus the default ROOT context deployed at
(tomcat_dir)/webapps/ROOT

and suppose you created 3 additional directories under webapps/ROOT, respectively

(tomcat_dir)/webapps/ROOT/app1
(tomcat_dir)/webapps/ROOT/app2
(tomcat_dir)/webapps/ROOT/app3

The standard Tomcat setup defines, in (tomcat_dir)/conf/web.xml, a "welcome file list" as

follows :
     <welcome-file-list>
         <welcome-file>index.html</welcome-file>
         <welcome-file>index.htm</welcome-file>
         <welcome-file>index.jsp</welcome-file>
     </welcome-file-list>

So, in each of the above new directories, you deploy a "index.jsp" page, like
(tomcat_dir)/webapps/ROOT/app1/index.jsp
(tomcat_dir)/webapps/ROOT/app2/index.jsp
(tomcat_dir)/webapps/ROOT/app3/index.jsp
, each of these pages displaying a nice message like :
"Sorry, this xyz application failed to deploy and is not available".

Then what would happen is :
- if all applications deploy properly, a request for the URL "/app1/x" would be mapped to

the application "app1"
- if app1 did not deploy properly, a request for the URL "/app1" would end up being mapped

to the default ROOT application and its sub-directory "/ROOT/app1", thus returning the 
welcome page (tomcat_dir)/webapps/ROOT/app1/index.jsp, and the message.

No ?

(The above was for the basic principle, but I suppose one could optimise this, to avoid 
having to create these sub-directories and duplicating those error pages, by mapping these

things more cleverly in ROOT's web.xml.)


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message