I am trying to use Rythm templating engine with servlet 3.0 on tomcat7.
I want to render template from WebContent
directory to Rythm
engine. But it is not detecting the template.
In servlet init()
method I initialized Rthym engine as
public void init(ServletConfig config) throws ServletException {
Map <String, Object> context = new HashMap <String, Object> ();
//String filePath = new File("").getAbsolutePath();
//filePath.concat("WebContent");
context.put("home.template", "WebContent");
Rythm.init(context);
}
then I tried to render my NewFile.html
with Rythm.render
in doGet
method as
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Map <String, Object> args = new HashMap <String, Object> ();
args.put("a", "World");
PrintWriter out = response.getWriter();
out.println(Rythm.render("NewFile.html", args));
}
But it is showing just "NewFile.html" in browser (Not content of NewFile.html but only String "NewFile.html"
I had a similar issue with Rythm and in my case it helped to write the directory in front of the filename:
Rythm.render("templates/" + templateFileName, parameters);
Setting the home.template
variable didn't work for me too.