Thread thread = Thread.currentThread();
ClassLoader oldLoader = thread.getContextClassLoader();
WebApp webApp = _webApp;
UserTransactionImpl ut = null;
if (_isTop)
ut = _utm.getUserTransaction();
try {
thread.setContextClassLoader(webApp.getClassLoader());
if (! webApp.enterWebApp() && webApp.getConfigException() == null) {
if (response instanceof HttpServletResponse) {
HttpServletResponse res = (HttpServletResponse) response;
res.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
}
return;
}
_next.doFilter(request, response);
} catch (Throwable e) {
_errorPageManager.sendServletError(e, request, response);
} finally {
webApp.exitWebApp();
// put finish() before access log so the session isn't tied up while
// logging
// needed for things like closing the session
if (request instanceof HttpServletRequestImpl)
((HttpServletRequestImpl) request).finishInvocation();
// server/1ld5
if (_isTop) {
((CauchoResponse) response).close();
try {
if (ut != null)
ut.abortTransaction();
} catch (Throwable e) {
log.log(Level.WARNING, e.toString(), e);
}
}