Examples of RequestDispatcher


Examples of javax.servlet.RequestDispatcher

            methodNotAllowed(response);
            return;
        }

        // get the dispatcher
        RequestDispatcher dispatcher = getServletContext().getNamedDispatcher(
                resourceName);
        if (dispatcher == null) {
            throw new ServletException(
                    "Cannot get a RequestDispatcher for name: " + resourceName);
        }

        // forward to the resource
        dispatcher.forward(request, response);

    }
View Full Code Here

Examples of javax.servlet.RequestDispatcher

    protected final String getDynamicQuery(String queryResource,
            HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        // get the dispatcher
        RequestDispatcher dispatcher = getServletContext()
                .getRequestDispatcher(queryResource);
        if (dispatcher == null) {
            throw new ServletException(
                    "Cannot get a RequestDispatcher for path: " + queryResource);
        }

        // set some useful information in the request
        request.setAttribute("path", ServletParameterUtils
                .getPathElements(request));

        // wrap the request in order to supply extra functionality (multiparm
        // form handling)
        CustomHttpServletRequestWrapper requestWrapper = new CustomHttpServletRequestWrapper(
                request, this.multipartSizeThreshold, this.multipartMaxSize,
                this.multipartRepositoryPath);

        // wrap our response, so we can capture the body (and the included
        // resource cannot mess with it)
        CustomHttpServletResponseWrapper responseWrapper = new CustomHttpServletResponseWrapper(
                response);

        // include the resource
        dispatcher.include(requestWrapper, responseWrapper);

        // and get the body
        String sql = responseWrapper.getBody();

        if (sql == null) {
View Full Code Here

Examples of javax.servlet.RequestDispatcher

     */
    private final void serveDefaultResource(String defaultResource,
            HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        // get the dispatcher
        RequestDispatcher dispatcher = getServletContext()
                .getRequestDispatcher(defaultResource);
        if (dispatcher == null) {
            throw new ServletException(
                    "Cannot get a RequestDispatcher for path: "
                            + defaultResource);
        }
        dispatcher.forward(request, response);
    }
View Full Code Here

Examples of javax.servlet.RequestDispatcher

            // loop through operations
            for (Iterator i = this.operations.iterator(); i.hasNext();) {
                Operation operation = (Operation) i.next();

                // get the dispatcher
                RequestDispatcher dispatcher = ServletParameterUtils
                        .getRequestDispatcher(context, operation
                                .getResourceNameOrPath());

                // wrap our request in order to override the HTTP method
                RequestWrapper requestWrapper = new RequestWrapper(request,
                        operation.getHttpMethod());

                // if this is the last operation just forward the request
                if (!i.hasNext()) {
                    dispatcher.forward(requestWrapper, response);
                    break;
                }

                // wrap our response in order to capture its body
                ResponseWrapper responseWrapper = new ResponseWrapper(response);

                // otherwise process this operation
                dispatcher.include(requestWrapper, responseWrapper);

                // check for successful response
                int responseStatus = responseWrapper.getStatus();
                if (responseStatus < 200 || responseStatus > 299) {
                    throw new ServletException("Operation "
View Full Code Here

Examples of javax.servlet.RequestDispatcher

    }

    public static RequestDispatcher getRequestDispatcher(
            ServletContext context, String resourceNameOrPath)
            throws ServletException {
        RequestDispatcher dispatcher = context
                .getNamedDispatcher(resourceNameOrPath);
        if (dispatcher == null) {
            dispatcher = context.getRequestDispatcher(resourceNameOrPath);
        }
        if (dispatcher == null) {
View Full Code Here

Examples of javax.servlet.RequestDispatcher

  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String key = request.getParameter("key");
    UserEntity user = getDao().getUserDao().getByKey(key);
    if (user == null || user.isDisabled()) {
      RequestDispatcher dispatcher = getServletContext()
          .getRequestDispatcher("/forgotPasswordFail.vm");
      dispatcher.forward(request,response);
    }
    else {
      user.setForgotPasswordKey(null);
      getDao().getUserDao().save(user);
      HttpSession session = request.getSession(true);
View Full Code Here

Examples of javax.servlet.RequestDispatcher

  public int getRemotePort() {
    return remotePort;
  }

  public RequestDispatcher getRequestDispatcher(String uri) {
    RequestDispatcher rd = registrations.getRequestDispatcher(uri);
    return rd;
  }
View Full Code Here

Examples of javax.servlet.RequestDispatcher

    try
    {
      String servlet = request.getHeader(SERVLET_HEADER);
      if (servlet == null)
        throw new IllegalArgumentException("Missing header: " + SERVLET_HEADER);
      RequestDispatcher requestDispatcher = getServletContext().getNamedDispatcher(servlet);
      if (requestDispatcher == null)
        throw new IllegalStateException("Could not found servlet with name " + servlet);
      request.getSession().setHandler(servlet);
      requestDispatcher.forward(request, null);
    }   
    catch (Throwable e)
    {
      sendError(request, e);
    }
View Full Code Here

Examples of javax.servlet.RequestDispatcher

    else {
      path = "/WEB-INF/" + path.replace('.', '/') + getExt();
    }

    // 执行 Forward
    RequestDispatcher rd = req.getRequestDispatcher(path);
    if (rd == null)
      throw Lang.makeThrow("Fail to find Forward '%s'", path);
    // Do rendering
    rd.forward(req, resp);
  }
View Full Code Here

Examples of javax.servlet.RequestDispatcher

  public void dispatch(String path)
    throws IOException
  {
    try {
      //_request.getRequestDispatcher(path).include(_request, _response);
      RequestDispatcher rd = _request.getRequestDispatcher(path);

      if (rd == null)
        throw new FacesException(L.l("'{0}' is an unknown dispatcher.",
                                     path));

     
      rd.forward(_request, _response);
    } catch (ServletException e) {
      throw new FacesException(e);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.