Example usage for javax.servlet.http HttpServletResponse sendRedirect

List of usage examples for javax.servlet.http HttpServletResponse sendRedirect

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletResponse sendRedirect.

Prototype

public void sendRedirect(String location) throws IOException;

Source Link

Document

Sends a temporary redirect response to the client using the specified redirect location URL and clears the buffer.

Usage

From source file:sample.mvc.ExpliotDemoController.java

@RequestMapping(value = "/csrf/messages/", method = RequestMethod.POST)
public void exploit(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Message messageToSave = messageParser.parse(request.getInputStream());

    messageRepository.save(messageToSave);

    response.sendRedirect(request.getContextPath());
}

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

public void redirectCancellingUser(HttpServletResponse response) throws IOException {
    try {/* w  w w . j a v a 2s  .co m*/
        response.sendRedirect(getRedirectionUriForCancellingUser());
    } catch (IOException e) {
        log.debug("Problem with re-direction", e);
        response.sendRedirect(getApplicationHomePageUrl());
    }
}

From source file:jp.co.opentone.bsol.linkbinder.view.filter.AbstractFilter.java

/**
 * ??./*from w  ww. java2  s  .c o m*/
 * @param request 
 * @param response ?
 * @param page 
 * @throws IOException 
 */
protected void redirectTo(HttpServletRequest request, HttpServletResponse response, String page)
        throws IOException {
    response.sendRedirect(String.format("%s%s", request.getContextPath(), page));
}

From source file:com.angstoverseer.web.servlet.ConsoleServlet.java

@Override
public void handleRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    final UserService userService = UserServiceFactory.getUserService();
    if (userService.getCurrentUser() == null) {
        response.sendRedirect(userService.createLoginURL(request.getRequestURI()));
    } else {//from   w  w  w .  j av  a 2s. c o  m
        response.getWriter().print(
                "<html><head><title>AOonGAE</title></head><body><script src='js/jquery/jquery-2.1.0.min.js'></script><script src='js/console/console.js'></script></body></html>");
    }
}

From source file:cz.muni.pa165.carparkapp.configuration.AuthenticationHandler.java

@Override
public void onAuthenticationSuccess(HttpServletRequest hsr, HttpServletResponse hsr1, Authentication a)
        throws IOException, ServletException {
    Set<String> roles = AuthorityUtils.authorityListToSet(a.getAuthorities());
    if (roles.contains("ROLE_USER")) {
        hsr1.sendRedirect(hsr.getContextPath() + "/");
    }// w ww  .j  a v  a 2  s.  com
    if (roles.contains("ROLE_ADMIN")) {
        hsr1.sendRedirect(hsr.getContextPath() + "/admin/");
    }
}

From source file:com.opiframe.utils.AutehnticationHandler.java

@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication a)
        throws IOException, ServletException {

    Set<String> roles = AuthorityUtils.authorityListToSet(a.getAuthorities());
    if (roles.contains("ROLE_USER")) {

        response.sendRedirect("/");
    }/*from w w w  .  j  av a2s .c  o  m*/
}

From source file:org.springside.modules.security.jcaptcha.JCaptchaFilter.java

/**
 * ?.//www .j a  v a 2  s.  c  om
 * 
 * ??, sessionSpringSecurityException.
 */
protected void redirectFailureUrl(final HttpServletRequest request, final HttpServletResponse response)
        throws IOException {
    response.sendRedirect(request.getContextPath() + failureUrl);
}

From source file:de.elatexam.UploadTaskdefServlet.java

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    UserService userService = UserServiceFactory.getUserService();
    if (!userService.isUserLoggedIn()) {
        resp.sendRedirect("/");
    } else {/*from  ww  w  .j  a v a 2 s.c o  m*/
        try {
            ServletFileUpload upload = new ServletFileUpload();

            FileItemIterator iterator = upload.getItemIterator(req);
            while (iterator.hasNext()) {
                FileItemStream item = iterator.next();

                long handle = System.nanoTime();
                DataStoreTaskFactory.getInstance().storeTaskDef(item.openStream(), handle,
                        userService.getCurrentUser());
            }
        } catch (Exception ex) {
            throw new ServletException(ex);
        }
        resp.sendRedirect("/");
    }

}

From source file:br.edu.ifpb.blogsoon.webapp.filter.Autorizacao.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    Usuario usuario = (Usuario) request.getSession().getAttribute("usuario");
    if (usuario != null) {
        return true;
    } else {/*from   w  w  w  . j a  v a 2 s  . c  o m*/
        response.sendRedirect("/");
        return false;
    }

}

From source file:ch.puzzle.modjprof.control.ControlServlet.java

private void deleteFiles(PrintWriter out, String baseURI, HttpServletResponse response) {
    invokeAgent("deleteAllTraceFiles", out);
    try {/*from  www.  j a v  a 2  s .  c  o  m*/
        response.sendRedirect(baseURI);
    } catch (IOException e) {
        printError(e, out);
    }
}