Example usage for javax.servlet RequestDispatcher forward

List of usage examples for javax.servlet RequestDispatcher forward

Introduction

In this page you can find the example usage for javax.servlet RequestDispatcher forward.

Prototype

public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException;

Source Link

Document

Forwards a request from a servlet to another resource (servlet, JSP file, or HTML file) on the server.

Usage

From source file:com.mycompany.CRMFly.ManagedBeans.AuthenticationBean.java

@Transactional
public String doLogin() throws IOException, ServletException {
    ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
    RequestDispatcher dispatcher = ((ServletRequest) context.getRequest())
            .getRequestDispatcher("/j_spring_security_check");
    dispatcher.forward((ServletRequest) context.getRequest(), (ServletResponse) context.getResponse());
    FacesContext.getCurrentInstance().responseComplete();
    return null;//from  w  w w  .  j  a  v a2  s  .  c  o  m
}

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 source file:org.apache.roller.weblogger.ui.core.filters.BootstrapFilter.java

public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
        throws IOException, ServletException {

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

    log.debug("Entered " + request.getRequestURI());

    if ("auto".equals(WebloggerConfig.getProperty("installation.type")) && !WebloggerFactory.isBootstrapped()
            && !isInstallUrl(request.getRequestURI())) {

        log.debug("Forwarding to install page");

        // we doing an install, so forward to installer
        RequestDispatcher rd = context.getRequestDispatcher("/roller-ui/install/install.rol");
        rd.forward(req, res);

    } else {/*from  w  w w.j  ava  2s.c  om*/
        chain.doFilter(request, response);
    }

    log.debug("Exiting " + request.getRequestURI());
}

From source file:com.mycompany.CRMFly.ManagedBeans.AuthenticationBean.java

@Transactional
public String doLogout() throws IOException, ServletException {
    ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
    RequestDispatcher dispatcher = ((ServletRequest) context.getRequest())
            .getRequestDispatcher("/j_spring_security_logout");
    dispatcher.forward((ServletRequest) context.getRequest(), (ServletResponse) context.getResponse());
    FacesContext.getCurrentInstance().responseComplete();
    return null;//w w  w  . java  2s  .  co m
}

From source file:uk.ac.ebi.intact.editor.security.LoginController.java

public String doLogin() throws IOException, ServletException {
    ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();

    RequestDispatcher dispatcher = ((ServletRequest) context.getRequest())
            .getRequestDispatcher("/j_spring_security_check");

    dispatcher.forward((ServletRequest) context.getRequest(), (ServletResponse) context.getResponse());

    FacesContext.getCurrentInstance().responseComplete();
    // It's OK to return null here because Faces is just going to exit.
    return null;/*from w  w  w  .  ja  va 2 s. co  m*/
}

From source file:com.navercorp.pinpoint.web.servlet.RewriteForV2Filter.java

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    if (enable) {
        HttpServletRequest req = (HttpServletRequest) request;
        String requestURI = req.getRequestURI();

        if (isRedirectTarget(requestURI)) {
            HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper((HttpServletRequest) request);
            RequestDispatcher dispatcher = wrapper.getRequestDispatcher("/v2/index.html");

            dispatcher.forward(request, response);
        } else {//w w  w.  j av  a  2  s.co m
            chain.doFilter(request, response);
        }
    } else {
        chain.doFilter(request, response);
    }

}

From source file:com.linuxbox.enkive.web.EnkiveServlet.java

/**
 * Helper function to make forwarding easier.
 * /*ww  w .  j a  v  a  2s.c om*/
 * @param url
 * @param req
 * @param resp
 * @throws ServletException
 * @throws IOException
 */
public void forward(String url, ServletRequest req, ServletResponse resp) throws ServletException, IOException {
    final RequestDispatcher dispatcher = req.getRequestDispatcher(url);
    dispatcher.forward(req, resp);
}

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

/**
 * /*www . j  a v 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 {

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

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

From source file:info.magnolia.cms.servlets.UUIDRequestDispatcher.java

/**
 * @param request/*from   w w w.  j av  a2s .co m*/
 * @param response
 * @throws javax.servlet.ServletException
 * @throws java.io.IOException
 */
public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String repositoryName = request.getParameter(ATTRIBUTE_REPOSITRY_NAME);
    String workspaceName = request.getParameter(ATTRIBUTE_WORKSPACE_NAME);
    String uuid = request.getParameter(ATTRIBUTE_UUID);
    String extension = Path.getExtension(request);
    if (StringUtils.isEmpty(repositoryName)) {
        repositoryName = ContentRepository.WEBSITE;
    }
    if (StringUtils.isEmpty(workspaceName)) {
        workspaceName = ContentRepository.getDefaultWorkspace(repositoryName);
    }
    try {
        String handle = ContentRepository.getHierarchyManager(repositoryName, workspaceName)
                .getContentByUUID(uuid).getHandle();
        handle = (handle + "." + extension);
        RequestDispatcher dispatcher = request.getRequestDispatcher(handle);
        dispatcher.forward(request, response);
    } catch (Exception e) {
        log.error("Failed to retrieve content for UUID : " + uuid + " , " + e.getMessage());
        if (log.isDebugEnabled())
            log.debug("Exception caught", e);
    }

}

From source file:hotel.web.util.RegistrationVerifier.java

/**
 * Processes requests for both HTTP/*from  ww  w.  ja v a2 s  .c  o  m*/
 * <code>GET</code> and
 * <code>POST</code> methods.
 *
 * @param request servlet request
 * @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 {
    response.setContentType("text/html;charset=UTF-8");
    String errMsg = "";
    String destination = "/registrationVerified.jsp";

    try {
        String id = request.getParameter("id");
        byte[] decoded = Base64.decode(id.getBytes());
        String username = new String(decoded);
        Users user = userService.find(username);
        if (user == null) {
            throw new RuntimeException("Sorry, that user is not in our system");
        }
        user.setEnabled(true);
        userService.edit(user);

    } catch (Exception dae) {
        errMsg = "VERIFICATION ERROR: " + dae.getLocalizedMessage();
        request.setAttribute("errMsg", errMsg);
        destination = "/registrationError.jsp";
    }

    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(destination);
    dispatcher.forward(request, response);

}