View | Details | Raw Unified | Return to bug 43668
Collapse All | Expand All

(-)ApplicationDispatcher.java (-28 / +23 lines)
Lines 138-143 Link Here
138
         * Are we performing an include() instead of a forward()?
138
         * Are we performing an include() instead of a forward()?
139
         */
139
         */
140
        boolean including = false;
140
        boolean including = false;
141
142
        /**
143
         * Outer most HttpServletRequest in the chain
144
         */
145
        HttpServletRequest hrequest = null;
146
147
        /**
148
         * Outermost HttpServletResponse in the chain
149
         */
150
        HttpServletResponse hresponse = null;
141
    }
151
    }
142
152
143
    // ----------------------------------------------------------- Constructors
153
    // ----------------------------------------------------------- Constructors
Lines 316-339 Link Here
316
            checkSameObjects(request, response);
326
            checkSameObjects(request, response);
317
        }
327
        }
318
328
319
        // Identify the HTTP-specific request and response objects (if any)
329
        wrapResponse(state);
320
        HttpServletRequest hrequest = null;
321
        if (request instanceof HttpServletRequest)
322
            hrequest = (HttpServletRequest) request;
323
        HttpServletResponse hresponse = null;
324
        if (response instanceof HttpServletResponse)
325
            hresponse = (HttpServletResponse) response;
326
327
        // Handle a non-HTTP forward by passing the existing request/response
328
        if ((hrequest == null) || (hresponse == null)) {
329
            processRequest(hrequest,hresponse,state);
330
        }
331
332
        // Handle an HTTP named dispatcher forward
330
        // Handle an HTTP named dispatcher forward
333
        else if ((servletPath == null) && (pathInfo == null)) {
331
        if ((servletPath == null) && (pathInfo == null)) {
334
332
335
            ApplicationHttpRequest wrequest =
333
            ApplicationHttpRequest wrequest =
336
                (ApplicationHttpRequest) wrapRequest(state);
334
                (ApplicationHttpRequest) wrapRequest(state);
335
            HttpServletRequest hrequest = state.hrequest;
337
            wrequest.setRequestURI(hrequest.getRequestURI());
336
            wrequest.setRequestURI(hrequest.getRequestURI());
338
            wrequest.setContextPath(hrequest.getContextPath());
337
            wrequest.setContextPath(hrequest.getContextPath());
339
            wrequest.setServletPath(hrequest.getServletPath());
338
            wrequest.setServletPath(hrequest.getServletPath());
Lines 349-355 Link Here
349
            ApplicationHttpRequest wrequest =
348
            ApplicationHttpRequest wrequest =
350
                (ApplicationHttpRequest) wrapRequest(state);
349
                (ApplicationHttpRequest) wrapRequest(state);
351
            String contextPath = context.getPath();
350
            String contextPath = context.getPath();
352
351
            HttpServletRequest hrequest = state.hrequest;
353
            if (hrequest.getAttribute(Globals.FORWARD_REQUEST_URI_ATTR) == null) {
352
            if (hrequest.getAttribute(Globals.FORWARD_REQUEST_URI_ATTR) == null) {
354
                wrequest.setAttribute(Globals.FORWARD_REQUEST_URI_ATTR,
353
                wrequest.setAttribute(Globals.FORWARD_REQUEST_URI_ATTR,
355
                                      hrequest.getRequestURI());
354
                                      hrequest.getRequestURI());
Lines 488-506 Link Here
488
        // Create a wrapped response to use for this request
487
        // Create a wrapped response to use for this request
489
        wrapResponse(state);
488
        wrapResponse(state);
490
489
491
        // Handle a non-HTTP include
492
        if (!(request instanceof HttpServletRequest) ||
493
            !(response instanceof HttpServletResponse)) {
494
            request.setAttribute(ApplicationFilterFactory.DISPATCHER_TYPE_ATTR,
495
                    Integer.valueOf(ApplicationFilterFactory.INCLUDE));
496
            request.setAttribute(
497
                    ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
498
                    servletPath);
499
            invoke(request, state.outerResponse, state);
500
        }
501
502
        // Handle an HTTP named dispatcher include
490
        // Handle an HTTP named dispatcher include
503
        else if (name != null) {
491
        if (name != null) {
504
492
505
            ApplicationHttpRequest wrequest =
493
            ApplicationHttpRequest wrequest =
506
                (ApplicationHttpRequest) wrapRequest(state);
494
                (ApplicationHttpRequest) wrapRequest(state);
Lines 584-590 Link Here
584
        }
572
        }
585
573
586
        // Initialize local variables we may need
574
        // Initialize local variables we may need
587
        HttpServletResponse hresponse = (HttpServletResponse) response;
575
        HttpServletResponse hresponse = state.hresponse;
588
        Servlet servlet = null;
576
        Servlet servlet = null;
589
        IOException ioException = null;
577
        IOException ioException = null;
590
        ServletException servletException = null;
578
        ServletException servletException = null;
Lines 817-822 Link Here
817
        ServletRequest previous = null;
805
        ServletRequest previous = null;
818
        ServletRequest current = state.outerRequest;
806
        ServletRequest current = state.outerRequest;
819
        while (current != null) {
807
        while (current != null) {
808
            if(state.hrequest == null && (current instanceof HttpServletRequest))
809
                state.hrequest = (HttpServletRequest)current;
820
            if ("org.apache.catalina.servlets.InvokerHttpRequest".
810
            if ("org.apache.catalina.servlets.InvokerHttpRequest".
821
                equals(current.getClass().getName()))
811
                equals(current.getClass().getName()))
822
                break; // KLUDGE - Make nested RD.forward() using invoker work
812
                break; // KLUDGE - Make nested RD.forward() using invoker work
Lines 878-883 Link Here
878
        ServletResponse previous = null;
868
        ServletResponse previous = null;
879
        ServletResponse current = state.outerResponse;
869
        ServletResponse current = state.outerResponse;
880
        while (current != null) {
870
        while (current != null) {
871
            if(state.hresponse == null && (current instanceof HttpServletResponse)) {
872
                state.hresponse = (HttpServletResponse)current;
873
                if(!state.including) // Forward only needs hresponse
874
                    return null;
875
            }
881
            if (!(current instanceof ServletResponseWrapper))
876
            if (!(current instanceof ServletResponseWrapper))
882
                break;
877
                break;
883
            if (current instanceof ApplicationHttpResponse)
878
            if (current instanceof ApplicationHttpResponse)

Return to bug 43668