On 8 Jul 2003 10:57:56 -0700,
(efiedler) wrote:
>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.
That's because this applies only to a particular user's session. If
the servlet is never called, there are no sessions.
>
>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
You shouldn't care whether a servlet is loaded or not; that's the
container's job. If you only care about the time interval since the
last call to the servlet, you can start a background thread in the
init() method that runs the code after a specified wait time. Every
time the servlet is called, you can reset this thread's countdown time
(with a synchronized method call) so that it only times out when there
has been no client activity.
You shouldn't put the code you want to run in the destroy() method,
either, because you have no way to control when destroy() is run. If
you really want it run after a certain period of time with no
activity, check that yourself as described above.
--
Phil Hanna
Author of JSP 2.0: The Complete Reference
http://www.philhanna.com
http://www.philhanna.com