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.boylesoftware.web.impl.view.DispatchViewSender.java

@Override
public void send(final String viewId, final HttpServletRequest request, final HttpServletResponse response)
        throws IOException, ServletException {

    if (request.isAsyncStarted()) {
        if (this.log.isDebugEnabled())
            this.log.debug("dispatching to " + viewId + " using async context");
        request.getAsyncContext().dispatch(viewId);
    } else {/*from  www.j a v  a  2 s . c  o m*/
        if (this.log.isDebugEnabled())
            this.log.debug("dispatching to " + viewId + " using request dispatcher");
        request.getRequestDispatcher(viewId).forward(request, response);
    }
}

From source file:cn.itcast.bbs.controller.BbsServlet.java

private void toLoginJsp(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    request.getRequestDispatcher("/WEB-INF/bbs/login.jsp").forward(request, response);
}

From source file:cn.itcast.bbs.controller.BbsServlet.java

private void toRegisterJsp(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    request.getRequestDispatcher("/WEB-INF/bbs/register.jsp").forward(request, response);
}

From source file:org.surfnet.oaaas.consent.FormUserConsentHandler.java

private boolean processForm(final HttpServletRequest request, final HttpServletResponse response)
        throws ServletException, IOException {
    if (Boolean.valueOf(request.getParameter(USER_OAUTH_APPROVAL))) {
        setAuthStateValue(request, request.getParameter(AUTH_STATE));
        String[] scopes = request.getParameterValues(GRANTED_SCOPES);
        setGrantedScopes(request, scopes);
        return true;
    } else {//  ww  w .  jav  a 2  s. c  o m
        request.getRequestDispatcher(getUserConsentDeniedUrl()).forward(request, response);
        return false;
    }
}

From source file:cz.muni.fi.myweb1.registerServlet.java

/**
 * Handles the HTTP <code>POST</code> method.
 *
 * @param request servlet request/*from w  w w.j av a 2  s . c o m*/
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    String name = (String) request.getAttribute("username");
    String password = (String) request.getAttribute("password");
    Boolean employee = Boolean.parseBoolean(request.getAttribute("employee").toString());

    if (myFacade.register(name, password, employee)) {
        request.getSession().setAttribute("username", name);
        RequestDispatcher rd = request.getRequestDispatcher("/outline.jsp");
        rd.forward(request, response);
    }

    else {
        //TODO error
    }
}

From source file:es.uma.inftel.blog.servlet.RegistroServlet.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
 *
 * @param request servlet request/*  www  .  j  av  a2s  .co  m*/
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    request.setCharacterEncoding("UTF-8");

    String username = request.getParameter("username");
    String password = request.getParameter("password");

    RegistroViewFacade registroViewFacade = new RegistroViewFacade(postFacade);

    RequestDispatcher registroRequestDispatcher = request.getRequestDispatcher("registro.jsp");
    if (username == null && password == null) {
        request.setAttribute("registroView", registroViewFacade.createView(false));
        registroRequestDispatcher.forward(request, response);
        return;
    }

    String email = request.getParameter("email");

    Part filePart = request.getPart("avatar");
    InputStream inputStream = filePart.getInputStream();
    byte[] avatar = IOUtils.toByteArray(inputStream);

    Usuario usuario = registrarUsuario(username, password, email, avatar);
    if (usuario == null) {
        request.setAttribute("registroView", registroViewFacade.createView(true));
        registroRequestDispatcher.forward(request, response);
    } else {
        HttpSession session = request.getSession();
        session.setAttribute("usuario", usuario);
        response.sendRedirect("index");
    }
}

From source file:com.hp.security.jauth.core.filter.AuthFilter.java

private void throwsException(HttpServletRequest request, ServletResponse servletResponse, Exception e)
        throws ServletException, IOException {
    e.printStackTrace();/*  w ww . j a va 2  s .  c om*/
    String exPage = SystemInit.exceptionPage;
    if (null != exPage && exPage.trim().length() > 0) {
        request.setAttribute("ex", e);
        request.getRequestDispatcher(exPage).forward(request, servletResponse);
    } else {
        exceptionUtil.throwDefaultTemplate(servletResponse, e);
    }
}

From source file:controller.servlet.PostServlet.java

private void requestNewPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    request.setAttribute(Constants.PAGE, "new-topic");
    CategoryDAOService catService = CategoryDAO.getInstance();
    request.setAttribute(Constants.LIST_CATEGORY, catService.getCategories());
    request.getRequestDispatcher(Constants.URL_HOME).forward(request, response);
}

From source file:com.jspxcms.core.setup.SetupServlet.java

protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    HttpSession session = request.getSession();
    Integer step = (Integer) session.getAttribute("step");
    if (step == null) {
        step = 0;//from   ww w.java  2  s.  c  om
    }
    RequestDispatcher rd = request.getRequestDispatcher(STEP_MAP.get(step));
    rd.forward(request, response);
}

From source file:com.mkmeier.quickerbooks.ProcessSquare.java

private void showForm(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    //Load Account Options
    Map<String, List<QbAccount>> accountLists = getAccountLists();

    HttpSession session = request.getSession(true);
    session.setAttribute("lists", accountLists);

    RequestDispatcher rd = request.getRequestDispatcher("SquareProcessor.jsp");
    rd.forward(request, response);/*from   w  w w . ja  v a 2s  .  c o  m*/
}