Examples of RequestDispatcherImpl


Examples of com.caucho.server.webapp.RequestDispatcherImpl

      return;

    if (user == null) {
      // A failure internally redirects to the error page (not redirect)
      String errorPage = login.getFormErrorPage();
      RequestDispatcherImpl disp;
      disp = (RequestDispatcherImpl) webApp.getRequestDispatcher(errorPage);

      // req.setAttribute("caucho.login", "login");
      if (res instanceof CauchoResponse) {
        ((CauchoResponse) res).killCache();
        ((CauchoResponse) res).setNoCache(true);
      }
      else {
        res.setDateHeader("Expires", 0);
        res.setHeader("Cache-Control", "no-cache");
      }
     
      disp.error(req, res);
      return;
    }
   
    HttpSession session = req.getSession();
   
    String uri = (String) session.getAttribute(FormLogin.LOGIN_SAVED_PATH);
    String query = (String) session.getAttribute(FormLogin.LOGIN_SAVED_QUERY);

    session.removeAttribute(FormLogin.LOGIN_SAVED_PATH);
    session.removeAttribute(FormLogin.LOGIN_SAVED_QUERY);

    if (log.isLoggable(Level.FINE)) {
      log.fine("old path:" + uri + " query:" + query + " j_uri:" +
               req.getParameter("j_uri"));
    }

    boolean formURIPriority = login.getFormURIPriority();

    // The saved uri has priority.
    if ((uri == null || formURIPriority) && req.getParameter("j_uri") != null)
      uri = req.getParameter("j_uri");
    else if (uri != null && query != null)
      uri = uri + "?" + query;

    if (uri == null) {
      log.warning(L.l("FormLogin: session has timed out for session '{0}'",
                      req.getSession().getId()));
     
      RequestDispatcher disp = request.getRequestDispatcher("/");
      if (disp != null) {
        disp.forward(request, response);
        return;
      }
      else {
        throw new ServletException(L.l("Session has timed out for form authentication, no forwarding URI is available.  Either the login form must specify j_uri or the session must have a saved URI."));
      }
    }

    if (uri.indexOf('\n') >= 0 || uri.indexOf('\r') >= 0)
      throw new ServletException(L.l("Forwarding URI '{0}' is invalid.",
                                     uri));

    String uriPwd = req.getRequestURI();
    int p = uriPwd.indexOf("/j_security_check");
    if (p >= 0)
      uriPwd = uriPwd.substring(0, p + 1);
   
    if (uri.length() == 0) {
    }
    else if (uri.charAt(0) == '/')
      uri = req.getContextPath() + uri;
    else if (uri.indexOf(':') >= 0 &&
             (uri.indexOf(':') < uri.indexOf('/') ||
              uri.indexOf('/') < 0)) {
    }
    else {
      uri = uriPwd + uri;
    }

    // The spec says that a successful login uses a redirect.  Resin
    // adds a configuration option to allow an internal forward
    // if the URL is in the same directory.
   
    // Logins to POST pages need to use an internal forward.
    // Most GETs will want a redirect.
    boolean useInternalForward = login.getInternalForward();
   
    if (useInternalForward
        && uri.startsWith(uriPwd)
        && uri.indexOf('/', uriPwd.length() + 1) < 0) {
      WebApp newApp = (WebApp) webApp.getContext(uri);
      String suffix = uri.substring(newApp.getContextPath().length());
     
      // force authorization of the page because the normal forward()
      // bypasses authorization
      RequestDispatcher disp = newApp.getLoginDispatcher(suffix);
      if (disp != null) {
        disp.forward(req, res);
        return;
      }
    }
   
    res.sendRedirect(res.encodeRedirectURL(uri));
View Full Code Here

Examples of com.caucho.server.webapp.RequestDispatcherImpl

      if (url != null) {
        if (webApp == null)
          webApp = getWebApp();

        RequestDispatcherImpl disp
          = (RequestDispatcherImpl) webApp.getRequestDispatcher(url);

        if (disp != null) {
          disp.dispatchResume(getRequestFacade(), getResponseFacade());

          return isSuspend();
        }
      }
View Full Code Here

Examples of com.caucho.server.webapp.RequestDispatcherImpl

      String url = _url;
     
      if (queryString != null)
        url = url + "?" + queryString;
     
      RequestDispatcherImpl disp
        = (RequestDispatcherImpl) req.getRequestDispatcher(url);

      disp.dispatch(request, response);
    } catch (FileNotFoundException e) {
      log.log(Level.FINE, e.toString(), e);
     
      res.sendError(404);
    }
View Full Code Here

Examples of com.caucho.server.webapp.RequestDispatcherImpl

  {
    HttpServletRequest req = (HttpServletRequest) request;
    HttpServletResponse res = (HttpServletResponse) response;

    try {
      RequestDispatcherImpl disp
        = (RequestDispatcherImpl) req.getRequestDispatcher(_url);

      disp.include(request, response);
    } catch (FileNotFoundException e) {
      log.log(Level.FINE, e.toString(), e);
     
      res.sendError(404);
    }
View Full Code Here

Examples of com.caucho.server.webapp.RequestDispatcherImpl

                       ServletResponse response)
    throws ServletException, IOException
  {
    HttpServletRequest req = (HttpServletRequest) request;

    RequestDispatcherImpl disp
      = (RequestDispatcherImpl) req.getRequestDispatcher(_url);

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

Examples of com.caucho.server.webapp.RequestDispatcherImpl

      return;

    if (user == null) {
      // A failure internally redirects to the error page (not redirect)
      String errorPage = login.getFormErrorPage();
      RequestDispatcherImpl disp;
      disp = (RequestDispatcherImpl) app.getRequestDispatcher(errorPage);

      // req.setAttribute("caucho.login", "login");
      if (res instanceof CauchoResponse) {
        ((CauchoResponse) res).killCache();
        ((CauchoResponse) res).setNoCache(true);
      }
      else {
  res.setDateHeader("Expires", 0);
  res.setHeader("Cache-Control", "no-cache");
      }
     
      disp.error(req, res);
      return;
    }
   
    HttpSession session = req.getSession();
   
    String uri = (String) session.getValue(FormLogin.LOGIN_SAVED_PATH);
    String query = (String) session.getValue(FormLogin.LOGIN_SAVED_QUERY);

    session.removeAttribute(FormLogin.LOGIN_SAVED_PATH);
    session.removeAttribute(FormLogin.LOGIN_SAVED_QUERY);

    if (log.isLoggable(Level.FINE)) {
      log.fine("old path:" + uri + " query:" + query + " j_uri:" +
               req.getParameter("j_uri"));
    }

    boolean formURIPriority = login.getFormURIPriority();

    // The saved uri has priority.
    if ((uri == null || formURIPriority) && req.getParameter("j_uri") != null)
      uri = req.getParameter("j_uri");
    else if (uri != null && query != null)
      uri = uri + "?" + query;

    if (uri == null) {
      log.warning(L.l("FormLogin: session has timed out for session '{0}'",
                      req.getSession().getId()));
     
      RequestDispatcher disp = request.getRequestDispatcher("/");
      if (disp != null) {
        disp.forward(request, response);
        return;
      }
      else {
        throw new ServletException(L.l("Session has timed out for form authentication, no forwarding URI is available.  Either the login form must specify j_uri or the session must have a saved URI."));
      }
    }

    if (uri.indexOf('\n') >= 0 || uri.indexOf('\r') >= 0)
      throw new ServletException(L.l("Forwarding URI '{0}' is invalid.",
             uri));

    String uriPwd = req.getRequestURI();
    int p = uriPwd.indexOf("/j_security_check");
    if (p >= 0)
      uriPwd = uriPwd.substring(0, p + 1);
   
    if (uri.length() == 0) {
    }
    else if (uri.charAt(0) == '/')
      uri = req.getContextPath() + uri;
    else if (uri.indexOf(':') >= 0 &&
             (uri.indexOf(':') < uri.indexOf('/') ||
              uri.indexOf('/') < 0)) {
    }
    else {
      uri = uriPwd + uri;
    }

    // The spec says that a successful login uses a redirect.  Resin
    // adds a configuration option to allow an internal forward
    // if the URL is in the same directory.
   
    // Logins to POST pages need to use an internal forward.
    // Most GETs will want a redirect.
    boolean useInternalForward = login.getInternalForward();
   
    if (useInternalForward
  && uri.startsWith(uriPwd)
  && uri.indexOf('/', uriPwd.length() + 1) < 0) {
      WebApp newApp = (WebApp) app.getContext(uri);
      String suffix = uri.substring(newApp.getContextPath().length());
     
      // force authorization of the page because the normal forward()
      // bypasses authorization
      RequestDispatcher disp = newApp.getLoginDispatcher(suffix);
      if (disp != null) {
  disp.forward(req, res);
  return;
      }
    }
   
    res.sendRedirect(res.encodeRedirectURL(uri));
View Full Code Here

Examples of com.caucho.server.webapp.RequestDispatcherImpl

      if (url != null) {
        if (webApp == null)
          webApp = getWebApp();

        RequestDispatcherImpl disp
          = (RequestDispatcherImpl) webApp.getRequestDispatcher(url);

        if (disp != null) {
          disp.dispatchResume(getRequestFacade(), getResponseFacade());

          return isSuspend();
        }
      }
View Full Code Here

Examples of io.undertow.servlet.spec.RequestDispatcherImpl

                        String location = servletContext.getDeployment().getErrorPages().getErrorLocation(t);
                        if (location == null) {
                            location = servletContext.getDeployment().getErrorPages().getErrorLocation(500);
                        }
                        if (location != null) {
                            RequestDispatcherImpl dispatcher = new RequestDispatcherImpl(location, servletContext);
                            try {
                                dispatcher.error(servletRequestContext, request, response, servletChain.getManagedServlet().getServletInfo().getName(), t);
                            } catch (Exception e) {
                                UndertowLogger.REQUEST_LOGGER.exceptionGeneratingErrorPage(e, location);
                            }
                        } else {
                            if (servletRequestContext.displayStackTraces()) {
View Full Code Here

Examples of io.undertow.servlet.spec.RequestDispatcherImpl

                        response.reset();                       //reset the response
                        exchange.setResponseCode(500);
                        exchange.getResponseHeaders().clear();
                        String location = servletContext.getDeployment().getErrorPages().getErrorLocation(t);
                        if (location != null) {
                            RequestDispatcherImpl dispatcher = new RequestDispatcherImpl(location, servletContext);
                            try {
                                dispatcher.error(request, response, servletChain.getManagedServlet().getServletInfo().getName(), t);
                            } catch (Exception e) {
                                UndertowLogger.REQUEST_LOGGER.errorf(e, "Exception while generating error page %s", location);
                            }
                        } else {
                            UndertowLogger.REQUEST_LOGGER.errorf(t, "Servlet request failed %s", exchange);
View Full Code Here

Examples of io.undertow.servlet.spec.RequestDispatcherImpl

            next.handleRequest(exchange);

            if (!exchange.isResponseStarted() && exchange.getResponseCode() >= 400 && !exchange.isDispatched()) {
                String location = servletContext.getDeployment().getErrorPages().getErrorLocation(exchange.getResponseCode());
                if (location != null) {
                    RequestDispatcherImpl dispatcher = new RequestDispatcherImpl(location, servletContext);
                    dispatcher.error(request, response, servletChain.getManagedServlet().getServletInfo().getName());
                }
            }
            //
        } catch (Throwable t) {
            if(request.isAsyncStarted() || request.getDispatcherType() == DispatcherType.ASYNC) {
                exchange.unDispatch();
                request.getAsyncContextInternal().handleError(t);
            } else {
                if (!exchange.isResponseStarted()) {
                    exchange.setResponseCode(500);
                    exchange.getResponseHeaders().clear();
                    String location = servletContext.getDeployment().getErrorPages().getErrorLocation(t);
                    if (location == null && t instanceof ServletException) {
                        location = servletContext.getDeployment().getErrorPages().getErrorLocation(t.getCause());
                    }
                    if (location != null) {
                        RequestDispatcherImpl dispatcher = new RequestDispatcherImpl(location, servletContext);
                        try {
                            dispatcher.error(request, response, servletChain.getManagedServlet().getServletInfo().getName(), t);
                        } catch (Exception e) {
                            UndertowLogger.REQUEST_LOGGER.errorf(e, "Exception while generating error page %s", location);
                        }
                    } else {
                        UndertowLogger.REQUEST_LOGGER.errorf(t, "Servlet request failed %s", exchange);
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.