Example usage for javax.servlet.http HttpServletResponse encodeRedirectUrl

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

Introduction

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

Prototype

@Deprecated
public String encodeRedirectUrl(String url);

Source Link

Usage

From source file:UrlRedirect.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, java.io.IOException {
    String contextPath = "http://www.java2s.com";
    response.sendRedirect(response.encodeRedirectURL(contextPath + "/maps"));
}

From source file:se.trillian.goodies.web.DisableSessionIdInUrlFilterTest.java

public void testSessionIdInEncodeUrlIsRemoved() throws Exception {
    final boolean[] called = new boolean[] { false };

    filter.doFilter(request, response, new FilterChain() {
        public void doFilter(ServletRequest req, ServletResponse res) throws IOException, ServletException {

            HttpServletResponse response = (HttpServletResponse) res;
            assertEquals("/home_en.html", response.encodeRedirectURL("/home_en.html"));
            assertEquals("/home_en.html", response.encodeURL("/home_en.html"));
            called[0] = true;//from  w ww .ja  v a2  s  .c o  m
        }
    });

    assertTrue(called[0]);
}

From source file:org.terasoluna.gfw.functionaltest.app.redirect.WhiteListRedirectStrategy.java

public void sendRedirect(HttpServletRequest request, HttpServletResponse response, String url)
        throws IOException {
    if (checkWhiteList(url)) {
        String redirectUrl = response.encodeRedirectURL(url);

        if (logger.isDebugEnabled()) {
            logger.debug("Redirecting to '" + redirectUrl + "'");
        }//from  w  ww.  ja  va2s  . co m

        response.sendRedirect(redirectUrl);

    } else {
        response.sendError(HttpServletResponse.SC_FORBIDDEN, url);
    }
}

From source file:grails.plugin.springsecurity.web.GrailsRedirectStrategy.java

public void sendRedirect(HttpServletRequest request, HttpServletResponse response, String url)
        throws IOException {
    String redirectUrl = calculateRedirectUrl(request, url);
    redirectUrl = response.encodeRedirectURL(redirectUrl);

    log.debug("Redirecting to '{}'", redirectUrl);

    response.sendRedirect(redirectUrl);//from w  w w.  ja v a  2s .  co m
}

From source file:org.jahia.bin.Login.java

protected String getRedirectUrl(HttpServletRequest request, HttpServletResponse response) {
    return response.encodeRedirectURL(StringUtils.defaultIfEmpty(request.getParameter("redirect"),
            request.getContextPath() + "/welcome"));
}

From source file:com.hp.autonomy.hod.sso.HodTokenLogoutSuccessHandlerTest.java

@Test
public void redirectsWithNoAuthentication() throws IOException, ServletException {
    final HttpServletRequest request = mock(HttpServletRequest.class);
    when(request.getContextPath()).thenReturn(CONTEXT_PATH);

    final String mockRedirectUrl = "/mock/redirect/url";
    final HttpServletResponse response = mock(HttpServletResponse.class);

    final String expectedPath = CONTEXT_PATH + REDIRECT_PATH;
    when(response.encodeRedirectURL(expectedPath)).thenReturn(mockRedirectUrl);

    logoutSuccessHandler.onLogoutSuccess(request, response, null);

    verify(response).sendRedirect(mockRedirectUrl);
}

From source file:com.exedio.cope.live.Anchor.java

void redirectHome(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
    response.sendRedirect(response.encodeRedirectURL(session.getHome(request)));
}

From source file:org.vaadin.spring.security.web.VaadinDefaultRedirectStrategy.java

@Override
public void sendRedirect(String url) {
    HttpServletRequest request = http.getCurrentRequest();
    HttpServletResponse response = http.getCurrentResponse();

    String redirectUrl = calculateRedirectUrl(request.getContextPath(), url);
    redirectUrl = response.encodeRedirectURL(redirectUrl);

    if (logger.isDebugEnabled()) {
        logger.debug("Redirecting to '" + redirectUrl + "'");
    }/*from w  w w.  ja  v  a  2s . c o  m*/

    // Change to Vaadin Redirect
    UI.getCurrent().getPage().setLocation(redirectUrl);
}

From source file:org.apache.myfaces.webapp.filter.JavaScriptDetectorFilter.java

public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
        throws IOException, ServletException {
    HttpServletRequest request = (HttpServletRequest) servletRequest;
    HttpServletResponse response = (HttpServletResponse) servletResponse;

    JavascriptUtils.setJavascriptDetected(request.getSession(true), true); // mark the session to use javascript

    String redirectURL = response.encodeRedirectURL(request.getParameter("goto"));
    log.info("Enabled JavaScript for session - redirect to " + redirectURL);
    response.sendRedirect(redirectURL);//from  w w  w  .  j a va  2s .  com
}

From source file:org.springframework.security.web.DefaultRedirectStrategy.java

/**
 * Redirects the response to the supplied URL.
 * <p>// w w w  .  ja  v a 2  s  .  co  m
 * If <tt>contextRelative</tt> is set, the redirect value will be the value after the
 * request context path. Note that this will result in the loss of protocol
 * information (HTTP or HTTPS), so will cause problems if a redirect is being
 * performed to change to HTTPS, for example.
 */
public void sendRedirect(HttpServletRequest request, HttpServletResponse response, String url)
        throws IOException {
    String redirectUrl = calculateRedirectUrl(request.getContextPath(), url);
    redirectUrl = response.encodeRedirectURL(redirectUrl);

    if (logger.isDebugEnabled()) {
        logger.debug("Redirecting to '" + redirectUrl + "'");
    }

    response.sendRedirect(redirectUrl);
}