Package javax.servlet.http

Examples of javax.servlet.http.HttpServletResponse.encodeRedirectURL()


        EasyMock.expect(mockRequest.getContextPath()).andReturn("").anyTimes();
        EasyMock.expect(mockRequest.getServletPath()).andReturn("").anyTimes();
       
        EasyMock.expect(mockRequest.getSession()).andReturn(internalSession).anyTimes();
       
        EasyMock.expect(mockResponse.encodeRedirectURL("http://localhost/loginpage")).andReturn("http://localhost/loginpage").atLeastOnce();
       
        try {
      mockResponse.sendRedirect("http://localhost/loginpage");
    } catch (IOException e) {
      fail(e.getMessage());
View Full Code Here


        HttpServletRequest httpRequest = (HttpServletRequest) request;
        HttpServletResponse httpResponse = (HttpServletResponse) response;

        String redirectUrl = buildRedirectUrlToLoginPage(httpRequest,
                httpResponse, accessDeniedException);
        httpResponse.sendRedirect(httpResponse.encodeRedirectURL(redirectUrl));
    }

    protected String buildRedirectUrlToLoginPage(HttpServletRequest request,
            HttpServletResponse response, AccessDeniedException authException) {
View Full Code Here

        HttpServletResponse response = ServletActionContext.getResponse();

        if (referer != null) {
            log.info("reload complete, reloading user back to: " + referer);
            saveMessage(getText("reload.succeeded"));
            response.sendRedirect(response.encodeRedirectURL(referer));
            return SUCCESS;
        } else {
            response.setContentType("text/html");

            PrintWriter out = response.getWriter();
View Full Code Here

    RequestCycle requestCycle = mock(RequestCycle.class);
    ThreadContext.setRequestCycle(requestCycle);
    when(requestCycle.getUrlRenderer()).thenReturn(renderer);

    HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
    when(httpServletResponse.encodeRedirectURL(Matchers.eq(url))).thenReturn(url + ";foo");

    ServletWebResponse webResponse = new ServletWebResponse(webRequest, httpServletResponse);
    assertEquals(url + ";foo", webResponse.encodeRedirectURL(url));
  }
}
View Full Code Here

        try
        {
          // send redirect - this will discard POST parameters if the request is POST
          // - still better than getting an error because of lacking trailing slash
          httpServletResponse.sendRedirect(httpServletResponse.encodeRedirectURL(redirectURL));
        }
        catch (IOException e)
        {
          throw new RuntimeException(e);
        }
View Full Code Here

    HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
    when(webRequest.getContainerRequest()).thenReturn(httpServletRequest);
    when(httpServletRequest.getCharacterEncoding()).thenReturn("UTF-8");

    HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
    when(httpServletResponse.encodeRedirectURL(Matchers.anyString())).thenReturn(url);
    StringWriter writer = new StringWriter();
    when(httpServletResponse.getWriter()).thenReturn(new PrintWriter(writer));

    ServletWebResponse webResponse = new ServletWebResponse(webRequest, httpServletResponse);
    webResponse.sendRedirect(url);
View Full Code Here

    baseUrl.setHost("someHost");
    baseUrl.setPort(80);
    when(webRequest.getClientUrl()).thenReturn(baseUrl);

    HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
    when(httpServletResponse.encodeRedirectURL(Matchers.anyString())).thenReturn(url);

    ServletWebResponse webResponse = new ServletWebResponse(webRequest, httpServletResponse);
    webResponse.sendRedirect(url);

    verify(httpServletResponse).sendRedirect("relative/path");
View Full Code Here

        try
        {
          // send redirect - this will discard POST parameters if the request is POST
          // - still better than getting an error because of lacking trailing slash
          httpServletResponse.sendRedirect(httpServletResponse.encodeRedirectURL(redirectURL));
        }
        catch (IOException e)
        {
          throw new RuntimeException(e);
        }
View Full Code Here

    HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
    when(webRequest.getContainerRequest()).thenReturn(httpServletRequest);
    when(httpServletRequest.getCharacterEncoding()).thenReturn("UTF-8");

    HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
    when(httpServletResponse.encodeRedirectURL(Matchers.eq(url))).thenReturn(url);
    StringWriter writer = new StringWriter();
    when(httpServletResponse.getWriter()).thenReturn(new PrintWriter(writer));

    ServletWebResponse webResponse = new ServletWebResponse(webRequest, httpServletResponse);
    webResponse.sendRedirect(url);
View Full Code Here

    ServletWebRequest webRequest = mock(ServletWebRequest.class);
    when(webRequest.isAjax()).thenReturn(Boolean.FALSE);

    HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
    when(httpServletResponse.encodeRedirectURL(Matchers.eq(url))).thenReturn(url);

    ServletWebResponse webResponse = new ServletWebResponse(webRequest, httpServletResponse);
    webResponse.sendRedirect(url);

    verify(httpServletResponse).sendRedirect(url);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.