tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: When will a servlet be un loaded
Date Thu, 01 Nov 2007 15:27:56 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Uma,

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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHKfB89CaO5/Lv0PARArSbAJ44eOuTJbkegTWKxTTXCDpLyDzDNACfQvO7
qMPCNGe5eJLc8ZJ0opRaIKE=
=Vjm4
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message