protected FreeMarkerPageContext() throws TemplateModelException
{
environment = Environment.getCurrentEnvironment();
TemplateModel appModel = environment.getGlobalVariable(
FreemarkerServlet.KEY_APPLICATION_PRIVATE);
if(!(appModel instanceof ServletContextHashModel)) {
appModel = environment.getGlobalVariable(
FreemarkerServlet.KEY_APPLICATION);
}
if(appModel instanceof ServletContextHashModel) {
this.servlet = ((ServletContextHashModel)appModel).getServlet();
}
else {
throw new TemplateModelException("Could not find an instance of " +
ServletContextHashModel.class.getName() +
" in the data model under either the name " +
FreemarkerServlet.KEY_APPLICATION_PRIVATE + " or " +
FreemarkerServlet.KEY_APPLICATION);
}
TemplateModel requestModel =
environment.getGlobalVariable(FreemarkerServlet.KEY_REQUEST_PRIVATE);
if(!(requestModel instanceof HttpRequestHashModel)) {
requestModel = environment.getGlobalVariable(
FreemarkerServlet.KEY_REQUEST);
}