Assume tha i opened a web application did some opertaions on the servlet .and i logged out .
Will the container will call the destroy method of that servlet immedately (Assuming the servlet is not serving any other client at that particular time).
Save India From Corruption - Anna Hazare.
posted 7 years ago
Almost certainly not. Although the servlet container probably will not call the method until the web app (or the complete server) is shut down, it is free to take servlets out of service any time it feels like it (after calling destroy, of course). It's at best possible to make guesses about when that will happen, not predictions. The servlet code must be written to take into account that init and destroy may be called multiple times at unpredictable intervals.