public void dispatchRequest()

in src/main/java/org/apache/sling/engine/impl/SlingRequestProcessorImpl.java [426:468]


    public void dispatchRequest(
            final ServletRequest request,
            final ServletResponse response,
            final Resource resource,
            final RequestPathInfo resolvedURL,
            final DispatchingInfo dispatchingInfo)
            throws IOException, ServletException {
        // we need a SlingHttpServletRequest/SlingHttpServletResponse tupel
        // to continue
        final SlingJakartaHttpServletRequest cRequest = RequestData.toSlingHttpServletRequest(request);
        final SlingJakartaHttpServletResponse cResponse = RequestData.toSlingHttpServletResponse(response);

        // check that we have all required services
        final ServletResolver sr = this.servletResolver;
        if (sr == null) {
            final int status = HttpServletResponse.SC_SERVICE_UNAVAILABLE;
            String errorMessage = "Required service missing (ServletResolver)";
            log.debug("{}, cannot dispatch requests, sending status {}", errorMessage, status);
            cResponse.sendError(status, errorMessage);
            return;
        }

        // get the request data (and btw check the correct type)
        final RequestData requestData = RequestData.getRequestData(cRequest);
        final ContentData oldContentData = requestData.getContentData();
        final ContentData contentData = requestData.setContent(resource, resolvedURL);

        final DispatchingInfo oldDispatchingInfo = requestData.getDispatchingInfo();
        requestData.setDispatchingInfo(dispatchingInfo);
        try {
            // resolve the servlet
            Servlet servlet = sr.resolve(cRequest);
            contentData.setServlet(servlet);

            final FilterChainType type = dispatchingInfo.getType() == DispatcherType.INCLUDE
                    ? FilterChainType.INCLUDE
                    : FilterChainType.FORWARD;
            processComponent(cRequest, cResponse, type);
        } finally {
            requestData.resetContent(oldContentData);
            requestData.setDispatchingInfo(oldDispatchingInfo);
        }
    }