-----------------------------
Please read the FAQ!
<http://java.apache.org/faq/>
-----------------------------
Martin Roeder wrote:
> -----------------------------
> Please read the FAQ!
> <http://java.apache.org/faq/>
> -----------------------------
>
> I have a servlet called Globals, which reads a config file and stores
> variables that can be accessed by other servlets.
> Now when the Globals servlet gets automatically started upon
> JServ-launch it reads the conf file and presents static methods to
> access the variables. After the session for this servlet times out, the
> servlet gets destroyed though and I have to reread the config file which
> takes too much time. Now a book tells me to make the servlet an allways
> running thread to make it persistent, but when I do this, the JServ
> engine still destroys the servlet if it's not called during the session
> timeout period.
>
Unless it's been modified, the only circumstances when Apache JServ calls
the destroy() method of a servlet is when you are shutting it down, or when
you are taking advantage of the automatic reloading on changes to servlet
classes. It is never based on when sessions expire, because other active
sessions might also be accessing that servlet.
Are you sure you are not calling destroy() on it yourself? If you are, by
the way, that's really bad -- because your servlet will think it was
destroyed but Apache JServ will not know about it, and will call destroy()
again later, thus breaking the servlet API contracts.
>
> Is there a way to solve such issues, where you want to leave Objects
> loaded?
>
Another approach would be to make "Globals" a non-servlet class, and use
static initializers to set things up the first time it is referenced.
You'd still want to reference it from a startup servlet to make sure this
happens ahead of normal use.
>
> thx
>
> Martin.
>
Craig McClanahan
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]