Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > how to determine when a servelt will unload????

Reply
Thread Tools

how to determine when a servelt will unload????

 
 
efiedler
Guest
Posts: n/a
 
      07-08-2003
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
 
Reply With Quote
 
 
 
 
Ben_
Guest
Posts: n/a
 
      07-08-2003
> 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 ?


 
Reply With Quote
 
 
 
 
John C. Bollinger
Guest
Posts: n/a
 
      07-08-2003
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


 
Reply With Quote
 
Phil Hanna
Guest
Posts: n/a
 
      07-09-2003
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determine Wireless Range from AP Winston Wireless Networking 7 08-15-2005 01:46 PM
Kabbalah - Opportunity to control & determine your destiny Sheperd of Kabbala Firefox 0 04-28-2005 08:26 PM
How to determine if a DLL is a COM DLL or .NET DLL Anushi ASP .Net 5 10-28-2004 01:59 PM
servelt newbie question maxwell Java 18 02-26-2004 05:20 AM
nuby: determine method passed and determine the receiver that received the method Peņa, Botp Ruby 1 01-24-2004 07:51 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57