tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Mutsaers <pe...@mutsaers.com>
Subject Webapp initialization (tomcat 4)
Date Tue, 15 May 2001 18:18:05 GMT
Hello,

I have some questions on webapp initialization.

sorry to send this to both tomcat-user and tomcat-dev; since I use
tomcat 4 I wasn't sure where to send this to. I hope that my questions
are answered by some brand new, not yet documented features of
tomcat-4 :)


Browsing through documents, it seems like the only way to create some
initial objects (such as a JDBC connection pool) in the ServetContext
is to create a Servlet with load-on-startup, which then in its init()
method can do some initialization.

This seems a bit clumsy to me, since I don't really need the Servlet
to handle requests. I just need some hook to initialize my
ServletContext with some objects.

Are there other (better) ways to do this?

If not: can I force the Servlet to be destroyed after my init() is
ready?


Another topic: Am I correct in believing that
ServletContext.getContext(uri) is the only way to obtain stuff from
another webapps' ServletContext?


In fact what I would like is to create a JDBC Connection Pool to be
shared amongst various webapps. I could create this pool Object in one
webapp (via the clumsy Servlet load-on-startup), then copy a reference
to the ServletContexts of the other webapps. This creates some
ordering problems (the other webapps may not run until the webapp
setting up the connection pool is ready).

It would be nicer if Tomcat, before initialising the webapps, would
offer the possibility for me to run some code. This code (in my case
creating the pool) should then create some initial context that all
webapps can access (in order to create a reference in their own
ServletContext).

I was hoping that in servlet.xml, within the <Host> scope I could
specify some Object to be shared between all <Context>'s.

Is something like this available?


After a day of searching through specs, mailing-list archives etc I
hope someone can help me :)


-- 
Peter Mutsaers  |  Dübendorf    | UNIX - Live free or die
plm@gmx.li      |  Switzerland  | Sent via FreeBSD 4.3-stable

Mime
View raw message