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:com.lyndir.lhunath.snaplog.webapp.servlet.AppLogoutServlet.java

/**
 * {@inheritDoc}/*from   ww  w .  j  a v a 2  s . c  o m*/
 */
@Override
public void invokeGet(final HttpServletRequest request, final HttpServletResponse response)
        throws ServletException, IOException {

    LOG.debug("invoke get");

    LoginManager.invalidateSession(request);
    response.sendRedirect(logoutExitPath);
}

From source file:com.museum_web.controller.ScenarioController.java

@RequestMapping("actions/deleteScenario")
public void delete(Scenario scenario, HttpServletResponse response) throws Exception {
    new ScenarioService().deleteScenario(scenario.getId());
    response.sendRedirect("../scenario");
}

From source file:org.apache.ofbiz.passport.event.GitHubEvents.java

/**
 * Redirect to GitHub login page./*w w w.  j a  va 2 s  .c o m*/
 * 
 * @return 
 */
public static String gitHubRedirect(HttpServletRequest request, HttpServletResponse response) {
    GenericValue oauth2GitHub = getOAuth2GitHubConfig(request);
    if (UtilValidate.isEmpty(oauth2GitHub)) {
        return "error";
    }

    String clientId = oauth2GitHub.getString(PassportUtil.COMMON_CLIENT_ID);
    String returnURI = oauth2GitHub.getString(PassportUtil.COMMON_RETURN_RUL);

    // Get user authorization code
    try {
        String state = System.currentTimeMillis() + String.valueOf((new Random(10)).nextLong());
        request.getSession().setAttribute(SESSION_GITHUB_STATE, state);
        String redirectUrl = TokenEndpoint + AuthorizeUri + "?client_id=" + clientId + "&scope=" + DEFAULT_SCOPE
                + "&redirect_uri=" + URLEncoder.encode(returnURI, "UTF-8") + "&state=" + state;
        Debug.logInfo("Request to GitHub: " + redirectUrl, module);
        response.sendRedirect(redirectUrl);
    } catch (NullPointerException e) {
        String errMsg = UtilProperties.getMessage(resource, "RedirectToGitHubOAuth2NullException",
                UtilHttp.getLocale(request));
        request.setAttribute("_ERROR_MESSAGE_", errMsg);
        return "error";
    } catch (IOException e) {
        Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.toString());
        String errMsg = UtilProperties.getMessage(resource, "RedirectToGitHubOAuth2Error", messageMap,
                UtilHttp.getLocale(request));
        request.setAttribute("_ERROR_MESSAGE_", errMsg);
        return "error";
    }

    return "success";
}

From source file:dijalmasilva.interceptors.TransactionInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {

    Usuario u = (Usuario) request.getSession().getAttribute("user");

    if (u == null) {
        response.sendRedirect("/home");
        return false;
    }/* w  w w  .j a v a 2  s. com*/

    return true;

    //        if (request.getSession().getAttribute("usuarioLogado") == null){
    //            response.sendRedirect("/index");
    //            return false;
    //        }
    //        
    //        return true;
}

From source file:org.consultjr.mvc.core.components.exceptions.ApplicationAccessDeniedHandler.java

@Override
public void handle(HttpServletRequest request, HttpServletResponse response,
        AccessDeniedException accessDeniedException) throws IOException, ServletException {
    //do some business logic, then redirect to errorPage url
    response.sendRedirect(errorPage);
}

From source file:com.museum_web.controller.ChallengeController.java

@RequestMapping("actions/deleteChallenge")
public void delete(Challenge c, HttpServletResponse response) throws IOException {

    cs.deleteChallenge(c.getChallengeId());
    response.sendRedirect("../challenge");

}

From source file:Controller.AdminController.java

@RequestMapping(value = "ProsesTambahAdmin.htm")
public void ProsesTambahAdmin(HttpServletResponse response, @ModelAttribute("Admin") Admin j)
        throws IOException {
    AdminImplement ai = new AdminImplement();
    ai.insert(j);/*from  w  ww .j  av  a2  s . c  o m*/
    response.sendRedirect("TampilAllAdmin.htm");
}

From source file:Controller.AdminController.java

@RequestMapping(value = "ProsesUpdateAdmin.htm")
public void ProsesUpdateAdmin(HttpServletResponse response, @ModelAttribute("Admin") Admin j)
        throws IOException {
    AdminImplement ai = new AdminImplement();
    ai.update(j);/*from   ww  w . j  a va2s.  c  o m*/
    response.sendRedirect("TampilAllAdmin.htm");
}

From source file:org.surfnet.oaaas.web.ClientController.java

@RequestMapping(value = "test", method = RequestMethod.POST, params = "step2")
public void step2(ModelMap modelMap, @ModelAttribute("settings") ClientSettings settings,
        HttpServletRequest request, HttpServletResponse response) throws IOException {
    response.sendRedirect(settings.getAuthorizationURLComplete());
}

From source file:ua.yandex.shad.socnet.web.usermanager.AuthenticationInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    String uri = request.getRequestURI();
    //System.out.println(uri);

    if (!userManager.isLoggedIn()) {
        response.sendRedirect("loginpage");
        return false;
    }/*from   w w  w  .  j a v a2s  .c  om*/
    //System.out.println(userManager.getUser());

    return true;
}