On 3/7/07, George, Nixon <[EMAIL PROTECTED]> wrote:
I am using the VelocityViewServlet. I tried specifying the template
folder as part of setting the default path in this code:
protected ExtendedProperties loadConfiguration(ServletConfig
config)
throws
IOException {
ExtendedProperties p = new ExtendedProperties();
String path = config.getServletContext().getRealPath("/");
if (path == null){
path = "/";
}
p.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH,
path+"\\templates\\");
return p;
}
no, the VelocityViewServlet doesn't use the FileResourceLoader, it
uses the WebappLoader. you also don't need to override
loadConfiguration() method. just create a velocity.properties file at
"/WEB-INF/velocity.properties" that contains the line:
webapp.resource.loader.path = /templates
(or something like that)
oh, and be sure that you are using VelocityTools 1.3, as the earlier
versions require you to tell the VelocityViewServlet where your
velocity.properties file is located explicitly. the default location
is new to 1.3.
But that didn't seem to work. If I put all the templates in the webapp
root, everything is dandy but it does not seem to like the way I am
specifying the template path. Also, I had to put the double backslashes
because I am on a windows env.
BTW, I searched for the WebappLoader tool but could not find it. Could
you send me the URL? Thanks.
if you are using the VelocityViewServlet, it uses it by default.
javadoc is here:
http://velocity.apache.org/tools/releases/1.3/javadoc/org/apache/velocity/tools/view/servlet/WebappLoader.html
-----Original Message-----
From: Nathan Bubna [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 07, 2007 5:06 PM
To: Velocity Users List
Subject: Re: Velocity template file path
- What servlet are you using? The VelocityServlet (which is
deprecated) or the VelocityViewServlet (which is part of VelocityTools
and is the replacement for the VelocityServlet)?
- Use of the FileResourceLoader in a webapp environment is not
recommended. The VelocityTools project comes with a WebappLoader that
is much better for webapps.
- If your templates are in /webapp/templates, then that is where you
should point the resource loader; it would not be enough to point it
at the webapp root and expect it to look for a "templates" folder
automatically.
- For examples of how to configure and use the VelocityViewServlet,
you might consider checking out the example applications that come
with VelocityTools.
On 3/7/07, Nixon Sunny <[EMAIL PROTECTED]> wrote:
> I am using the file resource loader to get the template. But, I am
having
> problems accessing it. Keeps getting error...
>
> org.apache.velocity.exception.ResourceNotFoundException: Unable to
find
> resource 'products.vm'
>
> My webapp structure is:
>
> webapp<root>
> |
> -- templates
>
> All my .vm files are inside the templates directory. I have overridden
the
> loadConfiguration() method to make the webapp root as my default file
load
> path. But, I guess thats not enough to point to the /webapp/templates
> directory. What am I missing?
>
> Thanks.
>
> _________________________________________________________________
> With tax season right around the corner, make sure to follow these few
> simple tips.
>
http://articles.moneycentral.msn.com/Taxes/PreparationTips/PreparationTi
ps.aspx?icid=HMFebtagline
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]