// Store the page in the request
request.setAttribute(WebloungeRequest.PAGE, page);
// Get hold of the page template
PageTemplate template = null;
try {
template = getPageTemplate(page, request);
template.setEnvironment(request.getEnvironment());
} catch (IllegalStateException e) {
logger.debug(e.getMessage());
DispatchUtils.sendInternalError(request, response);
return true;
}
// Does the template support the requested flavor?
if (!template.supportsFlavor(contentFlavor)) {
logger.warn("Template '{}' does not support requested flavor {}", template, contentFlavor);
DispatchUtils.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, request, response);
return true;
}
// Suggest a last modified data. Note that this may not be the final date
// as the page may contain content embedded from other pages that feature
// more recent modification dates
response.setModificationDate(page.getLastModified());
// Set the content type
String characterEncoding = response.getCharacterEncoding();
if (StringUtils.isNotBlank(characterEncoding))
response.setContentType("text/html; charset=" + characterEncoding.toLowerCase());
else
response.setContentType("text/html");
// Add the template's HTML header elements to the response if it's not
// only used in editing mode
for (HTMLHeadElement header : template.getHTMLHeaders()) {
if (!HTMLInclude.Use.Editor.equals(header.getUse()))
response.addHTMLHeader(header);
}
// Select the actual renderer by method and have it render the
// request. Since renderers are being pooled by the bundle, we
// have to return it after the request has finished.
try {
logger.debug("Rendering {} using page template '{}'", path, template);
template.render(request, response);
} catch (Throwable t) {
String params = RequestUtils.dumpParameters(request);
String msg = "Error rendering template '" + template + "' on '" + path + "' " + params;
Throwable o = t.getCause();
if (o != null) {