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.gigglinggnus.controllers.DisplayUtilizationController.java

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

    RequestDispatcher rd = request.getRequestDispatcher("/admin/display-utilization.jsp");
    rd.forward(request, response);//from w w  w  .  ja  v  a 2  s  . c om
}

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

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

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

private void redirectToErrorPage(HttpServletRequest request, HttpServletResponse response, String todoId)
        throws ServletException, IOException {
    request.setAttribute("error", MessageFormat.format(resourceBundle.getString("no.such.todo"), todoId));
    request.getRequestDispatcher(ERROR_PAGE).forward(request, response);
}

From source file:org.jboss.console.plugins.monitor.ManageSnapshotServlet.java

protected void error(String msg, HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    req.setAttribute("error", "Error: " + msg);
    req.getRequestDispatcher("/manageSnapshot.jsp").forward(req, resp);
    return;//ww  w  .j  a  v a2s.c om
}

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

private void doHelp(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    req.setAttribute("title", "SPARQL Query Builder");
    req.setAttribute("bodyJsp", "/admin/sparql.jsp");

    RequestDispatcher rd = req.getRequestDispatcher("/" + Controllers.BASIC_JSP);
    rd.forward(req, res);//from   ww w  .  j av  a  2 s . c om
}

From source file:web.mvc.servlets.MyServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServletContext());

    if (context == null) {
        request.getRequestDispatcher("WEB-INF/jsp/db-info-error.jsp").forward(request, response);
    }// w w  w . j  a va  2  s. c  o m

    DriverManagerDataSource dataSource = context.getBean(DriverManagerDataSource.class);
    List<InfoItem> data = new ArrayList<>();
    try {
        fillDataFromDataSource(data, dataSource);
    } catch (SQLException ex) {
        Logger.getLogger(MyServlet.class.getName()).log(Level.SEVERE, null, ex);
    }
    request.setAttribute("info", data);
    request.getRequestDispatcher("WEB-INF/jsp/db-info.jsp").forward(request, response);
}

From source file:com.example.cognitive.personality.DemoServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    req.setAttribute("content", getDefaultText());
    req.getRequestDispatcher("/pi/index.jsp").forward(req, resp);
}

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

/**
 * /* w  w  w . j  av a  2 s .  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 {

    ProxyServerModel proxyInfo = store.getProxy();
    req.setAttribute("proxyInfo", proxyInfo);

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

From source file:com.pe.nisira.movil.view.listener.SessionTimeoutFilter.java

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    System.out.println("filter called");
    final HttpServletRequest req = (HttpServletRequest) request;
    final HttpSession session = req.getSession(false);
    if (session != null && !session.isNew()) {
        chain.doFilter(request, response);
    } else {//from w w  w . j a va 2 s  .co m
        System.out.println("Has timed out");
        req.getRequestDispatcher("/index.xthml").forward(request, response);
    }
}

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

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    boolean authorized = securityService.isAuthorized(request);
    if (authorized) {
        // do MVC in here
        RequestDispatcher rd = request.getRequestDispatcher("WEB-INF/adduser.jsp");
        rd.include(request, response);//www.j  a va  2s .co  m
    } else {
        response.sendRedirect("/");
    }
}