tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: When will a servlet be un loaded
Date Thu, 01 Nov 2007 15:27:56 GMT
Hash: SHA1


Uma Kalluru wrote:
> If I specify a servlet to load-on-start, when will the container unload this
> servlet? Does the container un-load the servlet when the Servlet has no
> incoming requests?

I don't believe there's any standard behavior specified by the servlet
spec for when a servlet will be taken out of service. My guess is that a
servlet would never be taken out of service by a servlet container,
mostly because the overhead of managing that process would be worse than
simply letting it live in memory for the life of the server.

But you should not rely on this fact, because it's not in the
specification anywhere.

> If I need the servlet to be unloaded only when the container stops, how do I
> do this?

Does the servlet contain some special data or something? You're not
supposed to do that. If you need long-living objects available for your
application, you should be using a ServletContextListener to load them
on context start and then un-load them on context stop. The logical
place to store these objects in the meantime is in the ServletContext
(application scope) or in JNDI somewhere.

- -chris

Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla -


To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message