Search in sources :

Example 1 with ServletResponseHttpWrapper

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);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequest(javax.servlet.ServletRequest) ServletResponse(javax.servlet.ServletResponse) HttpServletResponse(javax.servlet.http.HttpServletResponse) ServletResponseHttpWrapper(org.eclipse.jetty.server.ServletResponseHttpWrapper) FilterChain(javax.servlet.FilterChain) ServletRequestHttpWrapper(org.eclipse.jetty.server.ServletRequestHttpWrapper)

Aggregations

FilterChain (javax.servlet.FilterChain)1 ServletRequest (javax.servlet.ServletRequest)1 ServletResponse (javax.servlet.ServletResponse)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 ServletRequestHttpWrapper (org.eclipse.jetty.server.ServletRequestHttpWrapper)1 ServletResponseHttpWrapper (org.eclipse.jetty.server.ServletResponseHttpWrapper)1