views:

89

answers:

1

Can someone tell how to stop an web application when critical error is met while initializing, for e.g. important property is missing which will affect the whole application, I want to halt the web application, if system.exit is not a good option, can anyone point how to bring down the application.

Pls don't tell me to log the error, send email, display error msg in the welcome, etc. I want to know is there a way within servlet one can stop the web application from loading and shutdown the application.

Thanks. San

+2  A: 

Your servlet init() method should throw a ServletException. This will indicate to the servlet container, that the servlet has failed to initialise properly, and shouldn't be used.

Consequently your application will be unavailable. It means that other applications hosted in your container will still be available, however.

Note this question re. calling System.exit() from within Tomcat. It may offer some additional info.

Brian Agnew