velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From saur...@cysphere.com (Saurabh Shukla)
Subject RE: Velocity not finding the template... Urgent...
Date Wed, 19 Sep 2001 08:58:23 GMT

Thanks A LOT.
Regards,
saurabh


-----Original Message-----
From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
Sent: Saturday, September 15, 2001 4:32 AM
To: velocity-user@jakarta.apache.org
Subject: Re: Velocity not finding the template... Urgent...


On 9/14/01 11:47 AM, "Saurabh Shukla" <saurabh@cysphere.com> wrote:

>
>
> hii,
>
> I am using Velocity-1.1 on RedHat 6.2.(rather trying to use), I  so far
were
> working on jsp's and this is the first time i am trying velocity.
>
>
> My web-app is in /home/saurabh/htdocs. I have got a template index.vm in
> htdocs. ie /home/saurabh/htdocs/index.vm
>
> getTemplate("index.vm") throws Resource not Found Exception.
>
> getTemplate("/home/saurabh/htdocs/index.vm") also throws Resource not
Found
> Exception.(This ideally should not happen)!!!!!!!!!

( I hope you don't think it should fail silently...)

> How ever if i put index.vm in /home/saurabh/ Velocity finds my template.
>
> Can any one please please please explain why is this happening ? Coz' if
> this is the way velocity works then i'll have to shift to jsp asap.

You also might have to ram a hot poker in your nostril.  Each would be
painful, and each wouldn't get the job done.

:)

The issue is that Velocity defaults to 'current directory' for finding
templates.  There are gigs of discussion about this issue, so if interested,
look back in list archives.

Velocity uses something called 'resource loaders' to load templates.  The
FileResourceLoader is the default loader used, and you have to do some basic
configuration to get things working for your environment.

For a good example, see the servet_example2 in the /examples directory of
the distribution.  This example shows how a servlet can self-configure the
template paths based on the location in the file system.

Also, that example shows how to load templates from jars of your templates
that are placed in the WEB-INF/lib directory.

Finally, take a look at the developer docs

http://jakarta.apache.org/velocity/developer-guide.html

See the section on configuring resource loaders.  This is an important and
flexible feature of Velocity, and a few minutes looking over the
documentation and examples will certainly pay off.

geir

--
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
If you look up, there are no limits - Japanese Proverb


Mime
View raw message