velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anders Lindback <>
Subject Re: Initializing multiple VelocityServlets
Date Sun, 22 Sep 2002 11:49:09 GMT
Geir Magnusson Jr. skrev:
> On 9/22/02 5:15 AM, "Petr Toman" <> wrote:
> > "RuntimeInstance is the thing that holds the ResourceManagerImpl which
> > holds the FileResourceLoader which holds the search path for templates.
> > Since it is initialized in VelocityInOutVariable in a static clause, no
> > servlet after the first one will ever get its own FileResourceLoader for
> > finding templates.
> > 
> > So far as I can make out, fixing this will require changes in a number
> > of places. actionframework's cannot just call its
> > base class's getTemplate() method as that relies on velocity's
> > RuntimeSingleton, which would introduce the same problem."
> The singleton used by VelocityServlet is the problem.
> I think the safest way out of this that requires little change is to simply
> do roll your own version of velocityservlet that uses the 'separate
> instance' runtime, using the VelocityEngine class rather than Velocity,
> which is a singleton.
> Then each of your servlets will have their own instance of the velocity
> engine.

Actually it trivial to let the servlets share the velocity engine -
make it a static class member and a singletion in a base class
that all servlets inherits from.

Anders Lindb├Ąck
PS VelocityServlet REALLY need to rewritten to be of any use
for enything else but toy servlets.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message