Example usage for javax.servlet.http HttpServletRequest getRequestDispatcher

List of usage examples for javax.servlet.http HttpServletRequest getRequestDispatcher

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getRequestDispatcher.

Prototype

public RequestDispatcher getRequestDispatcher(String path);

Source Link

Document

Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.

Usage

From source file:com.parallax.server.blocklyprop.servlets.PasswordResetRequestServlet.java

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String email = req.getParameter("email");
    if (Strings.isNullOrEmpty(email)) {
        req.getRequestDispatcher("WEB-INF/servlet/password-reset/reset-request.jsp").forward(req, resp);
    } else {// w  w w. j a v  a2  s .c o  m
        try {
            if (cloudSessionLocalUserService.requestPasswordReset(email)) {
                showTextilePage(req, resp, PasswordResetPage.RESET_REQUESTED);
                // req.getRequestDispatcher("WEB-INF/servlet/password-reset/reset-requested.jsp").forward(req, resp);
            } else {
                req.setAttribute("error", true);
                req.getRequestDispatcher("WEB-INF/servlet/password-reset/reset-request.jsp").forward(req, resp);
            }
        } catch (UnknownUserException ex) {
            req.setAttribute("unknownEmail", true);
            req.getRequestDispatcher("WEB-INF/servlet/password-reset/reset-request.jsp").forward(req, resp);
        } catch (InsufficientBucketTokensException ex) {
            req.setAttribute("insufficientTokens", true);
            req.getRequestDispatcher("WEB-INF/servlet/password-reset/reset-request.jsp").forward(req, resp);
        } catch (ServerException se) {
            req.setAttribute("server-error", "Server exception");
            req.getRequestDispatcher("WEB-INF/servlet/password-reset/reset-request.jsp").forward(req, resp);
        } catch (WrongAuthenticationSourceException ex) {
            log.info("Trying to request password reset of non local user!");
            req.setAttribute("wrongAuthenticationSource", true);
            req.getRequestDispatcher("WEB-INF/servlet/password-reset/reset-request.jsp").forward(req, resp);
        }
    }
}

From source file:com.netcracker.financeapp.controller.bank_card.BankCardDeleteServlet.java

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    int deleted_id = bankCardService.deleteCardByNumber(request.getParameter("cardListVal"));
    if (deleted_id > 0) {
        request.getRequestDispatcher("templates/success.jsp").forward(request, response);
    } else {//from   ww w . j a  v  a 2  s. c  om
        request.getRequestDispatcher("templates/error.jsp").forward(request, response);
    }
}

From source file:io.github.benas.todolist.web.servlet.todo.CreateTodoServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    request.setAttribute("today", new SimpleDateFormat(TodoListUtils.DATE_FORMAT).format(new Date()));
    request.getRequestDispatcher(CREATE_TODO_PAGE).forward(request, response);
}

From source file:org.guanxi.idp.service.UrlRewriter.java

/**
 * Rewrites an incoming URL based on the rules defined in services/url-rewriter.xml
 * If you want to map /SSO to /shibb/sso, do this:
 * -- in web.xml, add a servlet-mapping for /SSO to the Guanxi Identity Provider servlet
 * -- in services/url-rewriter.xml, add <entry key="SSO" value="/shibb/sso" />, omit the leading /
 *
 * @param request Standard HttpServletRequest
 * @param response Standard HttpServletResponse
 * @param object handler/*from w w w  .ja v a  2  s  .com*/
 * @return true
 * @throws Exception if an error occurs
 */
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object object)
        throws Exception {
    String[] parts = request.getRequestURI().split("/");
    if (urlMaps.containsKey(parts[parts.length - 1])) {
        request.getRequestDispatcher((String) urlMaps.get(parts[parts.length - 1])).forward(request, response);
        return false;
    }
    return true;
}

From source file:com.mockey.ui.UploadConfigurationServlet.java

/**
 * //  ww w.j av  a2s.  c o m
 * 
 * @param req
 *            basic request
 * @param resp
 *            basic resp
 * @throws ServletException
 *             basic
 * @throws IOException
 *             basic
 */
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    RequestDispatcher dispatch = req.getRequestDispatcher("/upload.jsp");
    dispatch.forward(req, resp);
}

From source file:io.muic.ooc.webapp.servlet.EditServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String username = request.getParameter("usernameEditFirst");
    request.setAttribute("username", username);
    RequestDispatcher rd = request.getRequestDispatcher("WEB-INF/edit.jsp");
    rd.include(request, response);/*  w  w  w.jav  a2 s  .c  o  m*/
}

From source file:com.parallax.server.blocklyprop.servlets.ConfirmRequestServlet.java

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String email = req.getParameter("email");
    if (Strings.isNullOrEmpty(email)) {
        req.getRequestDispatcher("WEB-INF/servlet/confirm/confirm-request.jsp").forward(req, resp);
    } else {/*  w  ww  .ja  v  a  2s .  co m*/
        try {
            if (cloudSessionLocalUserService.requestNewConfirmEmail(email)) {
                showTextilePage(req, resp, ConfirmPage.CONFIRM_REQUESTED);
                //req.getRequestDispatcher("WEB-INF/servlet/confirm/confirm-requested.jsp").forward(req, resp);
            } else {
                req.setAttribute("error", true);
                req.getRequestDispatcher("WEB-INF/servlet/confirm/confirm-request.jsp").forward(req, resp);
            }
        } catch (UnknownUserException ex) {
            req.setAttribute("unknownEmail", true);
            req.getRequestDispatcher("WEB-INF/servlet/confirm/confirm-request.jsp").forward(req, resp);
        } catch (InsufficientBucketTokensException ex) {
            req.setAttribute("insufficientTokens", true);
            req.getRequestDispatcher("WEB-INF/servlet/confirm/confirm-request.jsp").forward(req, resp);
        } catch (EmailAlreadyConfirmedException ex) {
            showTextilePage(req, resp, ConfirmPage.ALREADY_CONFIRMED);
            //req.getRequestDispatcher("WEB-INF/servlet/confirm/already-confirmed.jsp").forward(req, resp);
        } catch (ServerException se) {
            req.setAttribute("server-exception", "Server exception");
            req.getRequestDispatcher("WEB-INF/servlet/confirm/confirm-request.jsp").forward(req, resp);
        } catch (WrongAuthenticationSourceException ex) {
            log.info("Trying to request email confirm of non local user!");
            req.setAttribute("wrongAuthenticationSource", true);
            req.getRequestDispatcher("WEB-INF/servlet/confirm/confirm-request.jsp").forward(req, resp);
        }
    }
}

From source file:io.muic.ooc.servlet.LoginServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    if (SecurityService.isAuthorized(request)) {
        response.sendRedirect("/home");
    } else {/*from w  ww  .  jav a  2 s.  c  o m*/
        RequestDispatcher rd = request.getRequestDispatcher("/WEB-INF/login.jsp");
        rd.include(request, response);
    }
}

From source file:com.google.step2.example.consumer.servlet.LoginServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
    RequestDispatcher d = req.getRequestDispatcher(TEMPLATE_FILE);
    d.forward(req, resp);/*  w ww. j ava  2s .co  m*/
}

From source file:it.volaconnoi.servlet.CheckInServlet.java

/**
 * Handles the HTTP <code>GET</code> method.
 *
 * @param request servlet request//  w  w w  . j  a v a  2 s .  c  om
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String userPath = request.getServletPath();

    if (userPath.equals("/checkin")) {
        request.getRequestDispatcher("/WEB-INF/checkin/checkin.jsp").forward(request, response);
    }

    if (userPath.equals("/CheckinConfirm")) {
        String reservId = request.getParameter("reservId");

        CheckIn ci = new CheckIn();
        ci.setId(reservId);

        checkInFacade.create(ci);
    }
}