use of org.eclipse.jetty.server.ServletResponseHttpWrapper in project jetty.project by eclipse.
the class ServletHandler method doHandle.
@Override
public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
ServletHolder servlet_holder = (ServletHolder) baseRequest.getUserIdentityScope();
FilterChain chain = null;
// find the servlet
if (target.startsWith("/")) {
if (servlet_holder != null && _filterMappings != null && _filterMappings.length > 0)
chain = getFilterChain(baseRequest, target, servlet_holder);
} else {
if (servlet_holder != null) {
if (_filterMappings != null && _filterMappings.length > 0) {
chain = getFilterChain(baseRequest, null, servlet_holder);
}
}
}
if (LOG.isDebugEnabled())
LOG.debug("chain={}", chain);
try {
if (servlet_holder == null)
notFound(baseRequest, request, response);
else {
// unwrap any tunnelling of base Servlet request/responses
ServletRequest req = request;
if (req instanceof ServletRequestHttpWrapper)
req = ((ServletRequestHttpWrapper) req).getRequest();
ServletResponse res = response;
if (res instanceof ServletResponseHttpWrapper)
res = ((ServletResponseHttpWrapper) res).getResponse();
// Do the filter/handling thang
servlet_holder.prepare(baseRequest, req, res);
if (chain != null)
chain.doFilter(req, res);
else
servlet_holder.handle(baseRequest, req, res);
}
} finally {
if (servlet_holder != null)
baseRequest.setHandled(true);
}
}
Aggregations