velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <ge...@adeptra.com>
Subject Re: RNFE
Date Wed, 03 Jul 2002 16:02:10 GMT
On 7/3/02 11:48 AM, "Kevin Baynes" <kbaynes@seagullsw.com> wrote:

> Also, I still don't understand. :-)
> 
> I do understand that Velocity does not know about the servlet container,
> when you say "It assumes 'current working directory'...", what is the
> 'current working directory'? How do I determine it?

The velocity core is a general template engine - it has no ties to the
servlet APIs.  The File, Jar, Classpath are general purpose loaders that you
can use in any application.  The FileResourceLoader assumes that "." is the
place to load stuff from unless told otherwise.  Further, assume that any
relative paths specified to the FRL are relative to the current directory,
rather than 'root' for security reasons.  While these security reasons are
debatable, it still wouldn't solve the problem of working in a webapp.

Now, we realize that the original motivation for Velocity's inspiration
(WebMacro), and the majority of use of Velocity, is in webapp development.
Therefore, there is 'application specific' stuff you must do when using
Velocity, and that is figuring out where your webapp 'stuff' is deployed on
the file system when using the FileResourceLoader.  Of course, the servlet
spec doesn't required that a deployed webapp *be* on a disk (a war could be
unwound in memory), so for universal deployment, using the FRL is
discouraged (as you are going to get screwed at some point... :)

So, the WebappLoader uses the servlet API to find resources in the webapp
tree, independent of where the tree lives (disk or memory).  It's better for
this than the classpath resource loader, as that uses the 'current
classloader', which can be dorked with, as you are finding out in Tomcat 4.

Does this clear it up a little?


> 
> Thanks,
> 
> ~kevin
> 
>> -----Original Message-----
>> From: Geir Magnusson Jr. [mailto:geirm@adeptra.com]
>> Sent: Wednesday, July 03, 2002 11:26 AM
>> To: velocity-user@jakarta.apache.org
>> Subject: Re: RNFE
>> 
>> 
>> On 7/3/02 11:13 AM, "Kevin Baynes" <kbaynes@seagullsw.com> wrote:
>> 
>>> 
>>> I'm still working on this ResourceNotFoundException in Tomcat4 (detailed
>>> email yesterday).
>>> 
>>> I'm switching from ClasspathResourceLoader to FileResourceLoader for
>>> testing.
>>> 
>>> Using "file.resource.loader.path = templates" in my properties,
>> what is the
>>> expected location of the "templates" folder? In relation to what does
>>> Velocity look for that directory?
>> 
>> Velocity has no knowledge or expectation about working in the servlet
>> environment.  It assumes 'current working directory' for anything relative
>> (which everything must be...)
>> 
>> So what people tend to do is (in order of my preference)
>> 
>> 
>> 0)  WebappResourceLoader from velocity tools. (I think that's what it's
>> called - between meetings so can't check)
>> 
>> 1) Classpath resource loader : put the templates in a jar and toss in
>> WEB-INF/lib
>> 
>> 2) File resource loader : put a file.rsc.ldr.pth in the vel
>> props, but then
>> let the servlet API tell you the absolute location.  This is the
>> worst as it
>> won't always work in general servlet deployment.  However, for
>> development,
>> its nice.  See the examples/servlet_example2 example
>> 
>> --
>> Geir Magnusson Jr.
>> Research & Development, Adeptra Inc.
>> geirm@adeptra.com
>> +1-203-247-1713
>> 
>> 
>> 
>> --
>> To unsubscribe, e-mail:
> <mailto:velocity-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:velocity-user-help@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:
> <mailto:velocity-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:velocity-user-help@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr. 
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message