Package javax.servlet

Examples of javax.servlet.RequestDispatcher


        throw new JspException(L.l("URL `{0}' must start with `/' with context `{0}'", url, context));
       
      if (context != null && context.startsWith("/")) {
        ServletContext app = pageContext.getServletContext().getContext(context);

        RequestDispatcher disp = app.getRequestDispatcher(url);

        if (disp == null)
          throw new JspException(L.l("URL `{0}' does not map to any servlet",
                                     url));

        CauchoResponse response = (CauchoResponse) pageContext.getResponse();

        String charEncoding = getCharEncoding();

        if (charEncoding != null)
          response.getResponseStream().setEncoding(charEncoding);

        final ServletRequest request = pageContext.getRequest();

        disp.include(request, response);

        final Integer statusCode
          = (Integer) request.getAttribute("com.caucho.dispatch.response.statusCode");

        //jsp/1jif
        if (statusCode != null) {
          final int status = statusCode.intValue();

          if (status < 200 || status > 299) {
            String message = L.l(
              "c:import status code {0} received while serving {1}",
              statusCode,
              context + url);

            throw new JspException(message);
          }
        }

        /*
        int status = response.getStatus();

        if (status < 200 || status > 299) {
          String message = L.l(
            "c:import status code {0} received while serving {1}",
            status,
            context + url);

          throw new JspException(message);
        }
        */
      }
      else
        handleExternalBody(context + url);
     
      return;
    }

    int colon = url.indexOf(':');
    int slash = url.indexOf('/');
    if (slash == 0 || colon < 0 || slash < 0 || slash < colon) {
      ServletRequest request = pageContext.getRequest();
      CauchoResponse response = (CauchoResponse) pageContext.getResponse();

      String charEncoding = getCharEncoding();

      if (charEncoding != null)
        response.getResponseStream().setEncoding(charEncoding);

      RequestDispatcher disp = request.getRequestDispatcher(url);

      JstlImportResponseWrapper wrapper = new JstlImportResponseWrapper(response);
      disp.include(request, wrapper);

      //jsp/1jie
      int status = wrapper.getStatus();

      if (status < 200 || status > 299) {
View Full Code Here


                    HttpServletResponse response)
    throws IOException, ServletException
  {
    out.flushBuffer();
   
    RequestDispatcher disp;

    String path = _virtual.evalString(request, response);
   
    disp = request.getRequestDispatcher(path);

    disp.include(request, response);
  }
View Full Code Here

       
      if (context != null && context.startsWith("/")) {
        ServletContext app = pageContext.getServletContext().getContext(context);

        try {
          RequestDispatcher disp = app.getRequestDispatcher(url);

          if (disp == null)
            throw new JspException(L.l("URL `{0}' does not map to any servlet",
                                       url));

          CauchoResponse response = (CauchoResponse) pageContext.getResponse();
          response.getResponseStream().setEncoding(null);

          disp.include(pageContext.getRequest(), response);
        } catch (FileNotFoundException e) {
          throw new JspException(L.l("`{0}' is an unknown file or servlet.",
                                     url));
        }
      }
      else
        handleExternalBody(context + url);
     
      return;
    }

    int colon = url.indexOf(':');
    int slash = url.indexOf('/');
    if (slash == 0 || colon < 0 || slash < 0 || slash < colon) {
      ServletRequest request = pageContext.getRequest();

      try {
        RequestDispatcher disp = request.getRequestDispatcher(url);

        if (disp == null)
          throw new JspException(L.l("URL `{0}' does not map to any servlet",
                                     url));

        CauchoResponse response = (CauchoResponse) pageContext.getResponse();
        response.getResponseStream().setEncoding(null);

        disp.include(pageContext.getRequest(), response);
      } catch (FileNotFoundException e) {
        throw new JspException(L.l("URL `{0}' is an unknown file or servlet.",
                                   url));
      }
    }
View Full Code Here

      buildDispatchInvocation(dispatchInvocation);

      WebAppController controller = getWebAppController(includeInvocation);
      WebApp webApp = getWebApp(includeInvocation, controller, false);

      RequestDispatcher disp
        = new RequestDispatcherImpl(includeInvocation,
                                    forwardInvocation,
                                    errorInvocation,
                                    dispatchInvocation,
                                    requestInvocation,
View Full Code Here

      response.sendRedirect(response.encodeRedirectURL(path));
      return;
    }

    if (path.endsWith("/j_security_check")) {
      RequestDispatcher disp;
      disp = webApp.getNamedDispatcher("j_security_check");

      if (disp == null)
        throw new ServletException(L.l("j_security_check servlet must be defined to use form-based login."));

      disp.forward(request, response);
      return;
    }
  }
View Full Code Here

      else {
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0);
      }

      RequestDispatcher disp = webApp.getRequestDispatcher(_errorPage);
      disp.forward(request, response);
      return;
    }
    else if (uri.equals(_loginPage) || uri.equals(_errorPage)) {
      request.getRequestDispatcher(path).forward(request, response);
      return;
    }

    HttpSession session = request.getSession();

    session.setAttribute(LOGIN_SAVED_PATH, path);
    session.setAttribute(LOGIN_SAVED_QUERY, request.getQueryString());

    if (response instanceof CauchoResponse) {
      ((CauchoResponse) response).killCache();
      ((CauchoResponse) response).setNoCache(true);
    }
    else {
      response.setHeader("Cache-Control", "no-cache");
    }

    // In case where the authenticator is something like https:/
    if (! _loginPage.startsWith("/")) {
      response.sendRedirect(response.encodeRedirectURL(_loginPage));
      return;
    }

    // Forwards to the loginPage, never redirects according to the spec.
    request.setAttribute(LOGIN_CHECK, "login");
    //RequestDispatcher disp = app.getLoginDispatcher(loginPage);
    RequestDispatcher disp = webApp.getRequestDispatcher(_loginPage);
    disp.forward(request, response);

    if (log.isLoggable(Level.FINE))
      log.fine(this + " request '" + uri + "' has no authenticated user");
  }
View Full Code Here

      if (_disp != null)
        _disp.forward(request, response);
      else {
        HttpServletRequest req = (HttpServletRequest) request;

        RequestDispatcher disp = req.getRequestDispatcher(_url);

        disp.forward(request, response);
      }
    } catch (FileNotFoundException e) {
      log.log(Level.FINER, e.toString(), e);
     
      HttpServletResponse res = (HttpServletResponse) response;
View Full Code Here

            throw new TurbineException(
                "Template " + templateName + " not found in template paths");
        }

        // get the RequestDispatcher for the JSP
        RequestDispatcher dispatcher = data.getServletContext()
            .getRequestDispatcher(relativeTemplateName);

        try
        {
            if (isForward)
            {
                // forward the request to the JSP
                dispatcher.forward(data.getRequest(), data.getResponse());
            }
            else
            {
                data.getOut().flush();
                // include the JSP
                dispatcher.include(data.getRequest(), data.getResponse());
            }
        }
        catch (Exception e)
        {
            // as JSP service is in Alpha stage, let's try hard to send the
View Full Code Here

      HTMLOutput.writeHTMLFooter(out);
     
    } else {
      // otherwise show the blog
      RequestDispatcher dispatch = getServletContext()
          .getRequestDispatcher("ViewBlog");
      dispatch.forward(req, resp);
    }
  }
View Full Code Here

        service.updateBlogAuthor(email, nickName, name, bio, dob);
      } else {
        // do a create
        service.createBlogAuthor(email, nickName, name, bio, dob);
      }
      RequestDispatcher dispatch = getServletContext().getRequestDispatcher("/ViewAuthor");
      dispatch.forward(req, resp);
    }
  }
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.