Duane Murphy wrote:
> This is a reference to an older message (hey, I'm catching up ;-).
>
> It has been our experience that servlets marked as load at startup with a
> specific name are loaded for the life of the server. This is running on JWS (1.x
> (I think .2).
>
This behavior (automatic loading at startup time) is not required by the
specification, but is commonly implemented in servlet engines. "Life of the server"
loads, on the other hand, are more
problematic.
>
> Is this in general not true and just a side affect? What is the behaviour of
> servlets in this context? There are lots of "work arounds" talked about here,
> but is there a "correct" way to ensure that a servlet is not unloaded?
>
As far as the servlet API specification is concerned, you have *zero* guarantees that
your servlet will not be unloaded. For example, the 2.1 spec has this to say:
"The servlet engine is not required to keep a servlet loaded for
any period of time or for the life of the server. Servlet engines
are free to use servlets or retire them at any time. Therefore, you
should not rely on class or instance members to store state
information."
Therefore, any solution you find will be dependent on the features of the servlet
engine you are using. In the long run, you would be better off investigating
solutions other than servlets to
store information that should exist for the life of the servlet engine. In the 2.1
API, for example, the ServletContext.setAttribute() method seems like a good choice
for this sort of data.
Craig McClanahan
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html