final TemplateEngine templateEngine) throws Throwable {
try {
if (!hasHtmlSource()) {
processContext(req, res, servletContext, null);
} else {
final WebContext ctx = new WebContext(req, res, servletContext,
req.getLocale());
ctx.setVariable(VAR_CONTENT_NAME, getPageName());
ctx.setVariable(VAR_URL_NAME, '/' + getPageName());
ctx.setVariable(VAR_URL_AJAX_UPDATE_NAME, '/' + UGateAjaxUpdaterServlet.class.getSimpleName());
ctx.setVariable(VAR_URI_WEB_SOCKET_NAME, '/' + UGateWebSocketServlet.class.getSimpleName());
ctx.setVariable(VAR_REMOTE_USER, req.getRemoteUser());
final RequiredValues rvs = processContext(req, res, servletContext, ctx);
ctx.setVariable(VAR_TITLE_NAME,
rvs != null && rvs.getTitle() != null ? rvs.getTitle()
: RS.rbLabel(KEY.APP_TITLE));
ctx.setVariable(
VAR_HEADER_NAME,
rvs != null && rvs.getHeader() != null ? rvs
.getHeader() : RS.rbLabel(
KEY.APP_TITLE_USER,
(req.getRemoteUser() != null ? req
.getRemoteUser() : "")));
ctx.setVariable(
VAR_FOOTER_NAME,
rvs != null && rvs.getFooter() != null ? rvs
.getFooter() : RS.rbLabel(KEY.APP_TITLE));
templateEngine.process(getPageName(BaseController.class), ctx,
res.getWriter());