velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <ge...@optonline.net>
Subject Re: How to use velocity in a webapp?
Date Thu, 22 Mar 2001 16:32:40 GMT
"Henning P . Schmiedehausen" wrote:

> [SNIP]
> I am pretty sure that I am missing just a small piece of information
> here. But I'm not able to figure it out on my own. :-(

You are doing nothing wrong - I do the same thing, but take care of the
'relative' path problem in one of two ways :

1) jar the template directory and put that jar into WEB-INF/lib, and
then use the classpath loader.  That should solve it right off.

2) You can convert the relative path to an absolute one by overriding
the VelocityServlet method 

   protected Properties loadConfiguration(ServletConfig config )

and either do something like

  Properties p = super.loadConfiguration( config );

   // and now use  config.getServletContext().getRealPath()
   // to convert the relative path in the properties to the realpath

or load the properties yourself from the file and do the same thing with
getRealPath()

You should do the same thing with your logfile as well.  Any relative
path :)
I 
> 
> Do I have to get the pathes on my own from the servlet runner and
> override them before invoking velocity (just as turbine does and is
> described in the org.apache.velocity.runtime.Runtime documentation?)

I think that is just what I described...
 
> Or is there a simpler way to let velocity cooperate with the servlet
> runner? It reads the properties file correctly from the webapp path.

The easiest way is with the Classpath loader, but you still have the
problem of the logfile...

> Please answer directly as I am not (yet) am member of this mailing list.

Join the list!

geir

-- 
Geir Magnusson Jr.                               geirm@optonline.net
Developing for the web?  See http://jakarta.apache.org/velocity/

Mime
View raw message