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:dk.itst.oiosaml.sp.service.LoginHandler.java

private void promptIdp(RequestContext context, String returnUrl) throws ServletException, IOException {
    log.debug("Prompting user for IdP");

    Map<String, String> idps = new HashMap<String, String>();
    for (String id : context.getIdpMetadata().getEntityIDs()) {
        StringBuilder url = new StringBuilder(returnUrl);
        if (returnUrl.indexOf('?') > -1) {
            url.append("&");
        } else {//from  ww  w  . ja  v a 2  s .co m
            url.append("?");
        }
        url.append(Constants.DISCOVERY_ATTRIBUTE).append("=");
        url.append(Base64.encodeBytes(id.getBytes(), Base64.DONT_BREAK_LINES));
        idps.put(id, url.toString());
    }

    String servlet = context.getConfiguration().getString(Constants.PROP_DISCOVERY_PROMPT_SERVLET, null);
    if (servlet != null) {
        HttpServletRequest request = context.getRequest();
        request.setAttribute("entityIds", idps);
        request.getRequestDispatcher(servlet).forward(request, context.getResponse());
    } else {
        VelocityContext vc = new VelocityContext();
        vc.put("entityIds", idps);

        try {
            HTTPUtils.getEngine().mergeTemplate("/dk/itst/oiosaml/sp/service/idp.vm", vc,
                    context.getResponse().getWriter());
        } catch (Exception e) {
            log.error("Unable to render IdP list", e);
            throw new ServletException(e);
        }
    }

}

From source file:com.look.CreateUserServlet.java

/**
 * Stops adding user and forwards error message with request back to user
 * @param request/*from   w  w w  . j  a v  a2  s . c o m*/
 * @param response
 * @param message 
 */
private void stop(HttpServletRequest request, HttpServletResponse response, String message) {
    stop = true;
    request.setAttribute("message", message);
    try {
        request.getRequestDispatcher("/createAccount.jsp").forward(request, response);
    } catch (IOException | ServletException ex) {
        Logger.getLogger(CreateUserServlet.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:fr.opensagres.xdocreport.document.web.UploadXDocReportServlet.java

protected void doForward(IXDocReport report, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    if (report != null) {
        request.setAttribute(XDOCREPORT_ATTR_KEY, report);
    }/*  w w w  .  j a  va 2s  .  co  m*/
    request.getRequestDispatcher(LOADREPORT_JSP).forward(request, response);
}

From source file:com.netcracker.financeapp.controller.agent.AgentDeleteServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    ArrayList<String> agentList = agentService.getAgentNames();
    request.setAttribute("agentList", agentList);

    request.setAttribute("clearAgent", "Select Agent");
    request.getRequestDispatcher("agent/agentDelete.jsp").forward(request, response);

}

From source file:edu.cornell.mannlib.vitro.webapp.controller.jena.RDFUploadFormController.java

@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) {

    if (!isAuthorizedToDisplayPage(request, response, SimplePermission.USE_ADVANCED_DATA_TOOLS_PAGES.ACTION)) {
        return;/*from w w  w .java  2  s . co m*/
    }

    VitroRequest vreq = new VitroRequest(request);

    RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
    request.setAttribute("bodyJsp", "/templates/edit/specific/upload_rdf.jsp");
    request.setAttribute("title", "Ingest RDF Data");
    request.setAttribute("css", "<link rel=\"stylesheet\" type=\"text/css\" href=\""
            + vreq.getAppBean().getThemeDir() + "css/edit.css\"/>");

    try {
        rd.forward(request, response);
    } catch (Exception e) {
        log.error(this.getClass().getName() + " could not forward to view.");
        log.error(e.getMessage());
        log.error(e.getStackTrace());
    }

}

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

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    ArrayList<String> cardList = bankCardService.getBankCardNumbers();
    request.setAttribute("cardList", cardList);

    request.setAttribute("clearCard", "Select Card");
    request.getRequestDispatcher("bankCard/bankCardDelete.jsp").forward(request, response);

}

From source file:com.gigglinggnus.controllers.CheckinController.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    EntityManager em = (EntityManager) request.getSession().getAttribute("em");

    RequestDispatcher rd = request.getRequestDispatcher("/admin/check-in-student.jsp");
    rd.forward(request, response);/*from  ww  w  .  j  av  a  2  s. c o  m*/
}

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

/**
 * Redirect to the Load Accounts form./*  w  w w . j  a  v  a  2s .  c om*/
 *
 * @param request
 * @param response
 * @throws ServletException
 * @throws IOException
 */
private void redirect(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    RequestDispatcher rd = request.getRequestDispatcher("LoadAccounts.jsp");
    rd.forward(request, response);
}

From source file:io.github.benas.todolist.web.servlet.user.RegisterServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    request.setAttribute("registerTabStyle", "active");
    request.getRequestDispatcher(REGISTER_PAGE).forward(request, response);
}

From source file:com.cabguru.servlet.AddDriverServlet.java

private void dispatch(HttpServletRequest request, HttpServletResponse response, String callerPage, String msg) {

    try {//from  w ww. j a v  a  2s.  c  o m
        request.setAttribute("msg", msg);
        RequestDispatcher rd = request.getRequestDispatcher(callerPage);
        rd.forward(request, response);
    } catch (ServletException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

}