}
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);
}
if(requestModel instanceof HttpRequestHashModel) {
HttpRequestHashModel reqHash = (HttpRequestHashModel)requestModel;
this.request = reqHash.getRequest();
this.session = request.getSession(false);
this.response = reqHash.getResponse();
this.wrapper = reqHash.getObjectWrapper();
}
else {
throw new TemplateModelException("Could not find an instance of " +
HttpRequestHashModel.class.getName() +
" in the data model under either the name " +
FreemarkerServlet.KEY_REQUEST_PRIVATE + " or " +
FreemarkerServlet.KEY_REQUEST);
}