aspose file tools*
The moose likes Servlets and the fly likes What to do in case of servlet initialization failure ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "What to do in case of servlet initialization failure ?" Watch "What to do in case of servlet initialization failure ?" New topic
Author

What to do in case of servlet initialization failure ?

James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
I have a web application in which I will want to successfully initialize all servlets before making it available to users. As such I will want all servlets which access a database to make their connections in their init() methods, and if these don't succeed I want to alert the administrator, log the errors, and disallow access to the servlets. Is there a standard way of doing this ?
I have thought that I could load all servlets on startup which would call the init() methods in which the database connections are made. If any of these fail then I will want to disallow access to any of the servlets of the web application. Is there a way of disabling these servlets programmatically, or am I limited to paying attention to the console and error logs when I deploy the web application, and undeploy if any errors are encountered ?
Thanks in advance for any feedback.

-James
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12836
    
    5
Look at the servlet API - javax.servlet.UnavailableException - if a servlet throws this exception, either at the init stage or later, the servlet container will not try to send any requests to it.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What to do in case of servlet initialization failure ?