You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "DAVIS, SCOTT A. (AIT)" <SC...@msg.ameritech.com> on 2000/08/08 16:31:10 UTC

Servlet unloading

I'm new here, so I apologize if this has been brought up before.

Is it possible to set the amount of time since a servlet is last accessed
before Tomcat unloads the servlet from memory?  As far as I can tell, it
currently keeps servlets in memory indefinitely by default.

I'm working on a intranet application with a number of servlets which each
open a connection to a remote database on initialization and close it when
they are destroyed.  The remote database is rebooted at 5:30am each Monday
morning, breaking any existing connections with the servlets.  Tomcat has to
restarted for the servlets to reconnect the next time they are accessed.

The intranet application is only accessed during work hours during the week.
If I could set Tomcat to unload servlets after an hour or two of non-use, I
wouldn't have to restart Tomcat each Monday morning.  (Actually, I should
probably restart it anyway just to make sure, so this may be a moot point.)

I appreciate any help on this.

Thanks,

Scott Davis
BORN
scott.a.davis@ameritech.com
scott.davis@born.com

Re: Servlet unloading

Posted by Jakob Hummes <hu...@castify.net>.

"DAVIS, SCOTT A. (AIT)" wrote:

> Is it possible to set the amount of time since a servlet is last accessed
> before Tomcat unloads the servlet from memory? 

This I don't know, but ...

> I'm working on a intranet application with a number of servlets which each
> open a connection to a remote database on initialization and close it when
> they are destroyed.  The remote database is rebooted at 5:30am each Monday
> morning, breaking any existing connections with the servlets.  Tomcat has to
> restarted for the servlets to reconnect the next time they are accessed.

...you should rethink your design.  A better approach is to use a DB
connection pool.  It should check the status of a connection, and reopen
the connection if it is broken, before returning the connection to your
servlet.

HTH,
- Jakob