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 destroying the servlet  Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "destroying the servlet  " Watch "destroying the servlet  " New topic
Author

destroying the servlet

Shreenivaas Reddy
Greenhorn

Joined: Jul 04, 2006
Posts: 7
how many ways we can destroy the servlet in our program?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

What do you mean by "destroy" the servelt?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35224
    
    7
Not sure what exactly you're trying to do, but a web application does not concern itself with the lifecycle of servlets - the servlet container does.


Android appsImageJ pluginsJava web charts
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3829
Though you don't destroy a servlet, it's the job of container.

But if you will call System.exit() or you will shutdown the server then container will destroy the all the servlets... Right??? :roll:
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12266
    
    1
If what you want is to prevent a servlet from responding to requests, have it throw a javax.servlet.UnavailableException - the container will then reject requests.
In the Tomcat servlet engine you can use the Manager interface to stop, start or reload an entire "web application" - which might be many servlets and jsp.
In case you are wondering, the destroy() method is part of the servlet life cycle controled by the container and should never be called by your program. It exists so you can clean up resources used by the servlet when the container is removing the instance for some reason.
Bill


Java Resources at www.wbrogden.com
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by rathi ji:
Though you don't destroy a servlet, it's the job of container.

But if you will call System.exit() or you will shutdown the server then container will destroy the all the servlets... Right??? :roll:


Yes, and blowing the server up with a stick of dynamite will also destroy the servlet.
Neither would be a reasonable approach.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35224
    
    7
Sure, restarting the container (or even just the web app) will unload the servlets. Calling System.exit will not work if the container is running with a security manager, though.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: destroying the servlet
 
Similar Threads
Export in Excel
Is there any way to get Servlet Init Parameter using EL?
How can I change the sdk version of Websphere 4 if I already install it
Capturing Form Data
javascript, servlets and SVG