FastWriter out = new FastWriter(res.getOutputStream(),
res.getCharacterEncoding());
// The template name comes as extra path info
// /servlet/MacroView/templ.wm
// or as servlet path via a *.wm rule
// /templ.wm
String template = req.getPathInfo();
if (template == null) {
template = req.getServletPath();
template = template.substring(1); // cut off leading "/"
}
// If template is still null, we have a problem
if (template == null) {
throw new ServletException(
"No template specified as extra path info or servlet path");
}
try {
Template tmpl = wm.getTemplate(template);
WebContext context = wm.getWebContext(req, res);
tmpl.write(out, context);
}
catch (WebMacroException e) {
throw new ServletException(e);
}
finally {
out.flush();
}