The moose likes Java in General and the fly likes servlet unloading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "servlet unloading" Watch "servlet unloading" New topic

servlet unloading

rajeev holkar

Joined: Sep 13, 2000
Posts: 21
What are the various ways to unload a servlet?
more simply, when a servlet is called, it is loaded by the web server, the required method is called and after that the servlet is unloaded.
So when can I be sure that my servlet has been unloaded??
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
hi rajeev!
when the servlet is changed, old servlet will be unload.The servlet will be unloaded when the destroy method is can unload the servlet by explicitely calling the destroy method.
rajeev holkar

Joined: Sep 13, 2000
Posts: 21
The things are getting clearer ... thanks ...
But this leads to another one ...
i have coded a servlet and the servlet takes a value for a X variable from a file(txt or any other) in the INIT method and writes back the present(modified) value of the X variable to the same file in the DESTROY function.
Now after updating the value of X, i closed the browser.
1. In this case, is the DESTROY function called?
2. If not, then who should be responsible for updating the file.
3. what could be the exact sequence??
Thanks in advance ...
Steve Fahlbusch

Joined: Sep 18, 2000
Posts: 602

I have a question about the Distroy.
Will the distroy cause the servlet to be unload immeaditatly or is it like garbage collection?
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Closing the browser has nothing to do with the servlet. The servlet might not be unloaded for days or weeks (if you are running a Unix server). The servlet will only get unloaded when the server decides that it needs to unload the servlet usually for memory purposes.

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
rajeev holkar

Joined: Sep 13, 2000
Posts: 21
hmmmmmmmmmm .... this is something ....
Thanks Paul.
I agree. Here's the link:
subject: servlet unloading
It's not a secret anymore!