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
posted
0
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
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
posted
0
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.