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:net.sourceforge.fenixedu.presentationTier.Action.utils.RequestUtils.java

public static void sendLoginRedirect(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    response.sendRedirect(request.getContextPath() + "/login");
}

From source file:com.hortonworks.example.util.Util.java

public static void sendLoginRedirect(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    response.sendRedirect("http://localhost:2222/login/?referrer=" + getUrlEncodedRequestUrl(request));
}

From source file:org.codehaus.groovy.grails.plugins.springsecurity.RedirectUtils.java

/**
 * Send a redirect.// ww  w .j  a v a2 s .  c o  m
 * @param request  the request
 * @param response  the response
 * @param url the target url to redirect to
 * @throws IOException  if there's a problem
 */
public static void sendRedirect(final HttpServletRequest request, final HttpServletResponse response,
        final String url) throws IOException {

    String redirect = buildRedirectUrl(request, response, url);
    response.sendRedirect(response.encodeRedirectURL(redirect));
}

From source file:com.github.thorqin.webapi.oauth2.OAuthClient.java

/**
 * Redirect user's browser to authority server to obtain authorization code
 * @throws java.io.UnsupportedEncodingException
 * @see #makeAuthorizationUri//from w w w  . j a va2  s  .c o m
 * @see OAuthServer#getAuthorizationCodeRequest
 * @param authorityServerUri
 * @param response
 * @param clientId
 * @param redirectUri
 * @param scope
 * @param state 
 */
public static void redirectAuthorization(HttpServletResponse response, String authorityServerUri,
        String clientId, String redirectUri, String scope, String state) throws IOException {
    response.sendRedirect(makeAuthorizationUri(authorityServerUri, clientId, redirectUri, scope, state));
}

From source file:com.github.thorqin.webapi.oauth2.OAuthServer.java

public static void redirectAuthorizationSuccess(HttpServletResponse response, String redirectionUri,
        String code, String state) throws IOException {
    response.sendRedirect(makeAuthorizationSuccessUri(redirectionUri, code, state));
}

From source file:com.github.thorqin.webapi.oauth2.OAuthServer.java

public static void redirectAuthorizationFailed(HttpServletResponse response, String redirectionUri,
        OAuthError error, String errorDescription, String errorUri, String state) throws IOException {
    response.sendRedirect(makeAuthorizationFailedUri(redirectionUri, error, errorDescription, errorUri, state));
}

From source file:com.orchestra.portale.externalauth.FbAuthenticationManager.java

public static void fbLogin(HttpServletRequest request, HttpServletResponse response) {

    //Create Facebook login url
    String fb_url = FacebookUtils.getLoginURL();

    try {/*from   ww  w  . j av  a2 s.  c o m*/
        //Call Facebook login dialog
        response.sendRedirect(fb_url);

    } catch (IOException e) {
        //Call error manager
        e.printStackTrace();
    }

}

From source file:io.lavagna.web.security.HSTSFilter.java

private static void sendRedirectAbsolute(String baseApplicationUrl, HttpServletResponse resp, String page,
        Map<String, List<String>> params) throws IOException {
    UriComponents urlToRedirect = UriComponentsBuilder.fromHttpUrl(baseApplicationUrl).path(page)
            .queryParams(new LinkedMultiValueMap<>(params)).build();
    resp.sendRedirect(urlToRedirect.toUriString());
}

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

/**
 * Logged in, but with insufficient authorization. Send them to the home page
 * with a message. They won't be coming back.
 *//*w  ww. j  a  v  a 2  s .co  m*/
public static void redirectToInsufficientAuthorizationPage(HttpServletRequest request,
        HttpServletResponse response) {
    try {
        DisplayMessage.setMessage(request, I18n.bundle(request).text("insufficient_authorization"));
        response.sendRedirect(request.getContextPath());
    } catch (IOException e) {
        log.error("Could not redirect to show insufficient authorization.");
    }
}

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

/**
 * Not logged in. Send them to the login page, and then back to the page
 * that invoked this.//from  w w  w. jav  a  2  s .co m
 */
public static void redirectToLoginPage(HttpServletRequest request, HttpServletResponse response) {
    String returnUrl = assembleUrlToReturnHere(request);
    String loginUrlWithReturn = assembleLoginUrlWithReturn(request, returnUrl);

    try {
        response.sendRedirect(loginUrlWithReturn);
    } catch (IOException ioe) {
        log.error("Could not redirect to login page");
    }
}