if (debug) {
log("Requested template: " + StringUtil.jQuoteNoXSS(path));
}
Template template = null;
try {
template = config.getTemplate(
path,
deduceLocale(path, request, response));
} catch (FileNotFoundException e) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
Object attrContentType = template.getCustomAttribute("content_type");
if(attrContentType != null) {
response.setContentType(attrContentType.toString());
}
else {
if (noCharsetInContentType) {
response.setContentType(
contentType + "; charset=" + template.getEncoding());
} else {
response.setContentType(contentType);
}
}
// Set cache policy
setBrowserCachingPolicy(response);
ServletContext servletContext = getServletContext();
try {
TemplateModel model = createModel(wrapper, servletContext, request, response);
// Give subclasses a chance to hook into preprocessing
if (preTemplateProcess(request, response, template, model)) {
try {
// Process the template
template.process(model, response.getWriter());
} finally {
// Give subclasses a chance to hook into postprocessing
postTemplateProcess(request, response, template, model);
}
}