This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "servlet unloading" Watch "servlet unloading" New topic
Author

servlet unloading

rajeev holkar
Greenhorn

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??
Anonymous
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 called.you can unload the servlet by explicitely calling the destroy method.
rajeev holkar
Greenhorn

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 ...
rajeev
Steve Fahlbusch
Bartender

Joined: Sep 18, 2000
Posts: 557
    
    7

I have a question about the Distroy.
Will the distroy cause the servlet to be unload immeaditatly or is it like garbage collection?
Thanks
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
Greenhorn

Joined: Sep 13, 2000
Posts: 21
hmmmmmmmmmm .... this is something ....
Thanks Paul.
 
Don't get me started about those stupid light bulbs.
 
subject: servlet unloading
 
Similar Threads
why static should be avoided with web app?
destroy method
When is destroy of servlets exaclty called
overloading of init-service and destroy methods
servlet unloading