I have created a JSP version of SampleServlet.java (yes, I know the reasons
why I shouldn't). Everything works fine, except I cannot load the sample.vm
template.
I have tried it 2 ways:
1)
String path = getServletContext().getRealPath("/");
if (path == null) {
System.out.println(" SampleServlet.loadConfiguration() : unable to "
+ "get the current webapp root. Using '/'. Please
fix.");
path = "/";
}
Properties p = new Properties();
p.setProperty( Velocity.FILE_RESOURCE_LOADER_PATH, path );
Velocity.init(p);
String templateFile = "sample.vm";
Template template = Velocity.getTemplate(templateFile);
2)
Velocity.init();
String templateFile = getServletContext().getRealPath("sample.vm");
// next line always returns false...
out.print("template exists??" + Velocity.templateExists(templateFile));
Template template = Velocity.getTemplate(templateFile);
***
What is funny is they both return the full path to the file, yet the
template cannot be loaded. Could this be a context issue?
Thanks,
- julian
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>