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.