You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by John Sutherland <js...@appliedtheory.com> on 2001/01/12 16:22:32 UTC
Servlets..
I'm starting to use Velocity as a template engine.. Lack of developer
docs is hindering my progress, but I'm getting through it...
I have a small problem.. I'm trying to run Velocity with a simple
servlet (following SampleServlet example), but I need to set a few
runtime properties first... I can set the template path, but for some
reason the logfile path is not getting set, and its tossing the log file
into the default location... Using Tomcat 3.1, Velocity nightly build
20010108... Any ideas?? Here's my code:
public class VelocityTest extends VelocityServlet
{
public void init( ServletConfig config )
throws ServletException
{
Runtime.setDefaultProperties();
Runtime.setProperty(Runtime.RUNTIME_LOG, "../logs/velocity.log"
);
Runtime.setSourceProperty( Runtime.FILE_RESOURCE_LOADER_PATH,
"../webapps/velocity" );
super.init( config );
}
public Template handleRequest( org.apache.velocity.context.Context
ctx )
{
Template outty = null;
// extract request out of the ctx.
HttpServletRequest req = (HttpServletRequest) ctx.get(REQUEST);
HttpServletResponse resp = (HttpServletResponse)
ctx.get(RESPONSE);
try
{
ctx.put("test", "This is a test");
outty = Runtime.getTemplate("test.vm");
}
catch( Exception e )
{
e.printStackTrace(System.out);
}
return( outty );
}
}
--
John Sutherland
Software Engineer
JSutherl@AppliedTheory.com