File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes How to shut down container from within my servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to shut down container from within my servlet?" Watch "How to shut down container from within my servlet?" New topic
Author

How to shut down container from within my servlet?

Philippe Desrosiers
Ranch Hand

Joined: Mar 29, 2006
Posts: 138
Yeah, Iknow, seems like a ridiculous question, right? WhenI start Tomcat (5.5.15), and Tomcat starts my servlet, I want to be able to shut down the Tomcat container from code if there is no work to be done (ie: the servlet was not properly configured, or the database doesn't exist, or something).

Is there any way my servlet can shut down it's own container?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Why would you want to do such a thing?
Do you have no other access to the machine that your server is running under?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
dema rogatkin
Ranch Hand

Joined: Oct 09, 2002
Posts: 294
Try System.exit(..), however security manager can not allow this for a servlet. Most of servlet containers have admin web UI, so your servlet can use it to shutdown servlet container.


Tough in space?, <a href="http://tjws.sf.net" target="_blank" rel="nofollow">Get J2EE servlet container under 150Kbytes here</a><br />Love your iPod and want it anywhere?<a href="http://mediachest.sf.net" target="_blank" rel="nofollow">Check it here.</a><br /><a href="http://7bee.j2ee.us/book/Generics%20in%20JDK%201.5.html" target="_blank" rel="nofollow">Curious about generic in Java?</a><br /><a href="http://7bee.j2ee.us/bee/index-bee.html" target="_blank" rel="nofollow">Hate ant? Use bee.</a><br /><a href="http://7bee.j2ee.us/addressbook/" target="_blank" rel="nofollow">Need contacts anywhere?</a><br /><a href="http://searchdir.sourceforge.net/" target="_blank" rel="nofollow">How to promote your business with a search engine</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to shut down container from within my servlet?