req.getRequestURI(), req.getQueryString()));
}
String encoding = filterConfig.getEncoding();
String attrPrefix = filterConfig.getAttrPrefix();
// wrap response
JWebLiteResponseWrapper respWrapper = null;
if (resp instanceof JWebLiteResponseWrapper) {
respWrapper = (JWebLiteResponseWrapper) resp;
} else {
respWrapper = new JWebLiteResponseWrapper(req, resp, encoding,
filterConfig.isGZipEnabled());
}
WebContext context = new WebContext(req, respWrapper);
// prepare default variables
req.setAttribute(attrPrefix.concat("CP"), req.getContextPath());
// session manager
req.getSession(true).setAttribute(attrPrefix.concat("SessionManager"),
JWebLiteSessionManager.get());
try {
// parse form model
String formModelAttrName = attrPrefix.concat("FM");
FormModel formModel = (FormModel) req
.getAttribute(formModelAttrName);
if (formModel == null) {
formModel = new FormModel(req, encoding);
}
req.setAttribute(formModelAttrName, formModel);
// starting
boolean isIgnoreTemplate = false;
JWebLitePage reqClassInstance = null;
try {
// trigger doBeforeRequest event
application.doBeforeRequest(context, formModel);
// init class
reqClassInstance = doRequest(context, formModel);
} catch (SkipException se) {
isIgnoreTemplate = true;
}
// listener
doListener(respWrapper, reqClassInstance);
// pass the request along the filter chain
if (!isIgnoreTemplate) {
// trigger doBeforeRender event
application.doBeforeRender(context, formModel);
chain.doFilter(req, respWrapper);
}
// trigger doAfterRequest event
application.doAfterRequest(context, formModel);
// do finish
respWrapper.doFinish();
} catch (Throwable e) {
_cat.warn("Do filter failed!", e);
application.doError(context, e);
doErrorPage(filterConfig, req, respWrapper, e);
}