velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c_k...@bluemail.ch
Subject RE: template isn't found within a jsp
Date Fri, 06 Sep 2002 06:55:34 GMT
I've tried the same thing, but I used the singleton approach:
<%
Properties p = new Properties();
p.setProperty("file.resource.loader.path", application.getRealPath("/"));
Velocity.init(p);

VelocityContext context = new VelocityContext();
context.put( "name", "Hello World");

String templateName = "vc_test.vm";
Template template = Velocity.getTemplate(templateName);
template.merge( context, out);
%>
And this did not work.. So I thought your approach wouldn't work too.
But, It did work the way you proposed:
 
<%
VelocityEngine ve = new VelocityEngine();
Properties p = new Properties();
p.setProperty("file.resource.loader.path", application.getRealPath("/"));
ve.init(p);

VelocityContext context = new VelocityContext();
context.put( "name", "Hello World");

String templateName = "vc_test.vm";

Template template = ve.getTemplate(templateName);
template.merge( context, out);
%>

I don't know, why the singleton approach did not work (may be somebody can
give me an explanation)

But nevertheless, it works when I use the seperate Instance approach.

Thanks a lot for the Help!

Cornel

>I used this method in the initial conversion to Velocity so that the "links"
>to the JSP's didn't break.
>
>Try something like:
>
>VelocityEngine ve = new VelocityEngine();
>Properties p = new Properties();
>p.setProperty("file.resource.loader.path", "d:/path/to/my/templates");
>ve.init(p);
>




--
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