velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paulo Gaspar" <>
Subject RE: Multiple templates location/VelocityServlet instances
Date Thu, 01 Feb 2001 14:31:12 GMT
The way to have a single point of configuration in Tomcat is by using
a load-on-startup servlet that takes care of reading parameters and
initializing stuff.

This servlet does not have to be called. Such servlets are supposed to
be loaded and initialized before any servlet gets to process a request.

In the init() method of such servlet you can take care of initializing
application global objects and you can also free global resources on
its destroy() method.

You have a detailed example in Struts (another Jakarta project). In
their examples they have a "DatabaseServlet" that is used just to
initialize stuff.

Its configuration in web.xml is done like this:

  <!-- Database Initialization Servlet Configuration -->
    <load-on-startup>1</load-on-startup>  <!-- *** IMPORTANT *** -->

I think this is a good starting point for what you want to do.

Have fun,
Paulo Gaspar

> -----Original Message-----
> From: Shahar Solomianik []
> Sent: Thursday, February 01, 2001 14:36
> To:
> Subject: RE: Multiple templates location/VelocityServlet instances
> Hi geir.
> What I ment was that I just dont want my web.xml file full with same init
> parameters for all the servlets.
> It's not that it doesnt work.
> Shahar
> -----Original Message-----
> From: []On Behalf Of Geir
> Magnusson Jr.
> Sent: Thursday, February 01, 2001 2:13 AM
> To:
> Subject: Re: Multiple templates location/VelocityServlet instances
> Shahar Solomianik []
> > Them all are in one context.
> > so maybe I have to direct this question to tomcat, but :
> > Doesnt tomcat have a way to initialize derived servlets ?
> That question really doesn't make sense to me.  A servlet is simply an
> instance of a class, right? The servlet engine does something on the
> order of getInstance() to make one, and uses that for all the requests
> mapped to that servlet (generally).
> So tomcat simply init's the servlet - the fact that it's derived has no
> bearing on the matter.
> > Something like Apache JServ's, where I can have
> servlet.default.initArgs=...
> > to supply parameters needed by all servlets in a zone ?
> > After all, all my servlets will derive from VelocityServlet.
> If you have one properties file, all servlets can use it.  And once one
> servlet initializes Velocity, that's all you need - velocity is
> initialized and ready, and the rest of the servlets in that webapp
> context will use that initialized Velocity runtime. There is no harm in
> the other servlets' init() doing the Velocity initialization, as Vel
> protects itself.
> Does that clear it up a little?  Is there something I am missing?
> geir
> --
> Geir Magnusson Jr.                     
> Velocity : it's not just a good idea. It should be the law.

View raw message