Slava Kozlov wrote:
> > Kenneth,
> >
> > In a project I'm working on, we used the ServletContext to hold this
> > information as you said. To get this information loaded at
> > initialization time, we defined an initialization servlet and set it to
> > be preloaded. After that, all global objects were ready and available
> > for us to use.
> >
> > bab
> >
> > Brian Button [EMAIL PROTECTED]
> > Senior Consultant Object Mentor, Inc.
> > Products Review Editor C++ Report Magazine
>
> Do you also save state when the ServletContext (ie, web application) dies
> (servlet engine goes down, etc), using the initialization servlet?
>
I do this kind of state saving in the destroy() method of my initialization servlet,
and
rely on the servlet engine not to throw it out during normal running -- which it is
allowed to do. This is a workaround until the servlet API supports for-real
application
start and application end events that you can attach this kind of code to.
>
> --and--
>
> > But ServletContext will not address your problem. The Singleton will.
> >
> > Regards,
> >
> > Subrahmanyam
>
Note that the Singleton pattern does not solve the state-saving issue either.
It also fails horribly if you are running more than one app in the same server, and
they
both need the same Singleton class. There is an instance of ServletContext per web
application, so you do not run into this problem.
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