how to determine when a servelt will unload????  
Author Message
efiedler





PostPosted: 2003-7-9 1:58:00 Top

java-programmer, how to determine when a servelt will unload???? Hi -

I have a webpage that utilizes a servlet (written in JBuilder 7 and is
ran under Tomcat 4.0)...is there a way to find out how long of an idle
time is allowed (no calls to the servlet from the client) before the
servlet will be unloaded by Tomcat? And if I can find this out, can I
set this value somehow.

I have tried using the session.setmaxintervaltime but that does not
seem to work.

I would like to be able to kill the servlet after some set amount of
time so that I can run some code in the servelts destory method.

Thanks
 
Ben_





PostPosted: 2003-7-9 3:49:00 Top

java-programmer >> how to determine when a servelt will unload???? > I have a webpage that utilizes a servlet (written in JBuilder 7 and is
> ran under Tomcat 4.0)...is there a way to find out how long of an idle
> time is allowed (no calls to the servlet from the client) before the
> servlet will be unloaded by Tomcat? And if I can find this out, can I
> set this value somehow.

It's implementation dependent, see the Servlet Specification:
SRV.2.3.4 End of Service
The servlet container is not required to keep a servlet loaded for any
particular
period of time. A servlet instance may be kept active in a servlet container
for a
period of milliseconds, for the lifetime of the servlet container (which
could be a
number of days, months, or years), or any amount of time in between.
When the servlet container determines that a servlet should be removed from
service, it calls the destroy method of the Servlet interface to allow the
servlet to
release any resources it is using and save any persistent state. For
example, the
container may do this when it wants to conserve memory resources, or when it
is
being shut down.
Before the servlet container calls the destroy method, it must allow any
threads that are currently running in the service method of the servlet to
complete
execution, or exceed a server-defined time limit.
Once the destroy method is called on a servlet instance, the container may
not route other requests to that instance of the servlet. If the container
needs to
enable the servlet again, it must do so with a new instance of the servlet's
class.
After the destroy method completes, the servlet container must release the
servlet instance so that it is eligible for garbage collection.

> I have tried using the session.setmaxintervaltime but that does not
> seem to work.
Do not confuse Servlet life-cycle with session life-cycle.

> I would like to be able to kill the servlet after some set amount of
> time so that I can run some code in the servelts destory method.
What for ?


 
John C. Bollinger





PostPosted: 2003-7-9 5:12:00 Top

java-programmer >> how to determine when a servelt will unload???? efiedler wrote:
> I would like to be able to kill the servlet after some set amount of
> time so that I can run some code in the servelts destory method.

Then you are using the wrong tool for the job. If you explain the
bigger picture of what you want to accomplish then perhaps we can
suggest some alternatives.


John Bollinger
email***@***.com