tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: Such a thing as server startup class?
Date Tue, 07 Aug 2001 00:50:59 GMT


On Mon, 6 Aug 2001, Erik Weber wrote:

> > In a servlet 2.2 world, what most people do is declare a servlet to be
> > <load-on-startup> and initialize things in the init() method of that
> > servlet.  This is relying on the container to never unload that servlet
> > for the lifetime of the app (Tomcat doesn't unload anything until shutdown
> > time), but it basically works.
> >
> > Craig McClanahan
> 
> Good point. If the Servlet were to be unloaded, another instance would
> need to be loaded right away. Is there any (platform-independent) way
> to guarantee that at least one instance of a Servlet will always be
> loaded, even if it's not set up to handle HTTP requests?
> 

Sounds like time for my favorite URL reference - where to get the spec so
you can look stuff like this up for yourself :-)

  http://java.sun.com/products/servlet/download.html

On this particular issue, there is no such platform-independent API.  In
fact, the 2.2 and 2.3 specs explicitly remind you that you *cannot* rely
on "servlet will stay loaded" behavior in a portable application.  The
container is free (as far as the spec is concerned) to unload a loaded
servlet any time it feels like doing so.

That was one of the primary reasons that application event listeners were
added in 2.3 -- to give apps a portable mechanism that does not rely on
non-guaranteed assumptions about servlet lifetime, or on container
specific implementation features.

> -Erik
> 
> 

Craig



Mime
View raw message