Package javax.servlet

Examples of javax.servlet.RequestDispatcher


    protected void doInclude(
        ServletActionContext context,
        String uri)
        throws IOException, ServletException {

        RequestDispatcher rd = getRequiredDispatcher(context, uri);

        if (rd != null) {
            rd.include(context.getRequest(), context.getResponse());
        }
    }
View Full Code Here


    protected void doForward(
        ServletActionContext context,
        String uri)
        throws IOException, ServletException {

        RequestDispatcher rd = getRequiredDispatcher(context, uri);

        if (rd != null) {
            rd.forward(context.getRequest(), context.getResponse());
        }
    }
View Full Code Here

     * @param uri the ServletContext-relative URI of the request dispatcher to find.
     * @return the <code>RequestDispatcher</code>, or null if none is returned from the <code>ServletContext</code>.
     * @throws IOException if <code>getRequestDispatcher(uri)</code> has an error.
     */
    private RequestDispatcher getRequiredDispatcher(ServletActionContext context, String uri) throws IOException {
        RequestDispatcher rd = context.getContext().getRequestDispatcher(uri);
        if (rd == null) {
            log.debug("No request dispatcher found for " + uri);
            HttpServletResponse response = context.getResponse();
            response.sendError(
                HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
View Full Code Here

            doMessage(request, response);
        }
    }

    private void doMessage(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/sampleNotInstalled.jsp");
        dispatcher.forward(request, response);
    }
View Full Code Here

       
        boolean customServletPath = dispatcherServletPath != null;
        String theServletPath = customServletPath ? dispatcherServletPath : "/";
       
        ServletContext sc = super.getServletContext();
        RequestDispatcher rd = dispatcherServletName != null
            ? sc.getNamedDispatcher(dispatcherServletName)
            : sc.getRequestDispatcher((theServletPath + pathInfo).replace("//", "/"));
        if (rd == null) {
            String errorMessage = "No RequestDispatcher can be created for path " + pathInfo;
            if (dispatcherServletName != null) {
                errorMessage += ", dispatcher name: " + dispatcherServletName;
            }
            throw new ServletException(errorMessage);
        }
        try {
            for (Map.Entry<String, String> entry : redirectAttributes.entrySet()) {
                request.setAttribute(entry.getKey(), entry.getValue());
            }
            HttpServletRequestFilter servletRequest =
                new HttpServletRequestFilter(request, pathInfo, theServletPath, customServletPath);
            rd.forward(servletRequest, response);
        } catch (Throwable ex) {
            throw new ServletException("RequestDispatcher for path " + pathInfo + " has failed");
        }  
    }
View Full Code Here

public class TestOutTag extends ServletTestCase {

    public void testValue() throws Exception {
        request.setAttribute("cats", new StringReader("cats & dogs"));
        request.setAttribute("dogs", new StringReader("cats & dogs"));
        RequestDispatcher rd = config.getServletContext().getRequestDispatcher(TestUtil.getTestJsp(this));
        rd.forward(request, response);
    }
View Full Code Here

        }

        request = new HeadServletRequest(request);
        response = new HeadServletResponse(response);

        RequestDispatcher dispatcher = request.getRequestDispatcher(request.getResource());
        if (dispatcher != null) {
            dispatcher.forward(request, response);
        }
    }
View Full Code Here

            }
        }

        try {
            // create a dispatcher for the resource or path
            RequestDispatcher dispatcher;
            if (resource != null) {
                dispatcher = request.getRequestDispatcher(resource, opts);
            } else {
                dispatcher = request.getRequestDispatcher(path, opts);
            }
View Full Code Here

    /**
     * @see org.apache.sling.api.scripting.SlingScriptHelper#include(java.lang.String, org.apache.sling.api.request.RequestDispatcherOptions)
     */
    public void include(String path, RequestDispatcherOptions options) {
        final RequestDispatcher dispatcher = getRequest().getRequestDispatcher(
            path, options);

        if (dispatcher != null) {
            try {
                dispatcher.include(getRequest(), getResponse());
            } catch (IOException ioe) {
                throw new SlingIOException(ioe);
            } catch (ServletException se) {
                throw new SlingServletException(se);
            }
View Full Code Here

    /**
     * @see org.apache.sling.api.scripting.SlingScriptHelper#forward(java.lang.String, org.apache.sling.api.request.RequestDispatcherOptions)
     */
    public void forward(String path, RequestDispatcherOptions options) {
        final RequestDispatcher dispatcher = getRequest().getRequestDispatcher(
            path, options);

        if (dispatcher != null) {
            try {
                dispatcher.forward(getRequest(), getResponse());
            } catch (IOException ioe) {
                throw new SlingIOException(ioe);
            } catch (ServletException se) {
                throw new SlingServletException(se);
            }
View Full Code Here

TOP

Related Classes of javax.servlet.RequestDispatcher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.