You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Zsolt Koppany <zk...@intland.com> on 2001/05/28 17:22:53 UTC

Starting and stopping servlets on tomcat startup and shutdown

Hi,

as the subject shows is it possible that tomcat calls a class when
tomcat is just started or when it is shutting down?
My application needs database and some other external resources and it
would be nice if I could control those resources depending on the status
of tomcat.

Zsolt

-- 
Zsolt Koppany
Intland GmbH www.intland.com
Schulze-Delitzsch-Strasse 16
D-70565 Stuttgart
Tel: +49-711-7871080 Fax: +49-711-7871017

Re: Starting and stopping servlets on tomcat startup and shutdown

Posted by Bernd Koecke <bk...@schlund.de>.
Hi,

we needed the same functionality and I solved it with an own
Interceptor. You could inherit from BaseInterceptor and than you get
various callbacks (engineInit, engineShutdown etc). But I don't know if
this Interface/Class changes in newer versions of tomcat, we use 3.2.1.
Another posibility is, you write a servlet and move your startupcode in
the init-Method and the shutdowncode in the destroy-Method and set
'load-on-startup' in your web.xml-file. But these Methods could be
called if the servlet-environment decides to kill an unused Servelt if
it gets low on resources. But I don't know if tomcat behaves likes this.
Because of the ClassLoader the loaded Classes of your Servlet are only
visible in the containing webapp.

Hope this helps, bye

Bernd

Zsolt Koppany wrote:
> 
> Hi,
> 
> as the subject shows is it possible that tomcat calls a class when
> tomcat is just started or when it is shutting down?
> My application needs database and some other external resources and it
> would be nice if I could control those resources depending on the status
> of tomcat.
> 
> Zsolt
> 
> --
> Zsolt Koppany
> Intland GmbH www.intland.com
> Schulze-Delitzsch-Strasse 16
> D-70565 Stuttgart
> Tel: +49-711-7871080 Fax: +49-711-7871017

-- 
Dipl.-Inform. Bernd Koecke
UNIX-Entwicklung
Schlund+Partner AG
Fon: +49-721-91374-0
E-Mail: bk@schlund.de

RE: JDBC Connections

Posted by Paulo J S Pereira <pa...@sentex.net>.
Mathew,

It's been my experience to only use it when necessary and release it back to
the pool when done. Otherwise, it is redundant to have a pool to being with.
The pool's power comes in its management of "available" connections, if you
minimize the available connections, the pool will try to grow and eventually
lose it's effectiveness. You will also experience a performance hit for it.

Persistance layer implementaions rely on that principal in managing its
connection pool.

Paulo Pereira
Java/Web Developer
Sentricity Inc.,
A Division of Sentex Communications Corp.,
www.sentricity.com

-----Original Message-----
From: Mathew Clark [mailto:matt@genicomsystems.com]
Sent: Monday, May 28, 2001 11:38 AM
To: tomcat-user@jakarta.apache.org
Subject: JDBC Connections


Hi,

We have implemented a simple JDBC connection pool for our servlet - do you
think it is better to grab a connection once when a request is received and
use that connection throughout the processing or should the connection be
used only when necessary and released as soon as possible??

Regards,

Matthew.


JDBC Connections

Posted by Mathew Clark <ma...@genicomsystems.com>.
Hi,

We have implemented a simple JDBC connection pool for our servlet - do you
think it is better to grab a connection once when a request is received and
use that connection throughout the processing or should the connection be
used only when necessary and released as soon as possible??

Regards,

Matthew.