Package javax.servlet.http

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


        private void redirect(RequestContext context)
        {
            HttpServletResponse response = context.getResponse();

            String finalURL = response.encodeRedirectURL(_location);

            try
            {
                response.sendRedirect(finalURL);
            }
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

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

    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

    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

      log.debug("Remote address for request is: " + httpReq.getRemoteAddr());
    }
    String requestURI = httpReq.getRequestURI();
    if(!requestURI.startsWith(wsContextRoot) &&
       !getProxyAddresses().contains(httpReq.getRemoteAddr())) {
      String redirectUrl = httpResp.encodeRedirectURL(proxyUriBase +
                                                      requestURI);
      httpResp.sendRedirect(redirectUrl);
      return;
    }
   
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

        String defaultPortal = configService.getDefaultPortal();
        PortalURLContext urlContext = new PortalURLContext(context, SiteKey.portal(defaultPortal));
        NodeURL url = urlFactory.newURL(NodeURL.TYPE, urlContext);
        String s = url.setResource(new NavigationResource(SiteType.PORTAL, defaultPortal, "")).toString();
        HttpServletResponse resp = context.getResponse();
        resp.sendRedirect(resp.encodeRedirectURL(s));
        return true;
    }

    @Override
    protected boolean getRequiresLifeCycle() {
View Full Code Here

        HttpServletRequest request = context.getRequest();
        HttpServletResponse response = context.getResponse();

        if (requestURI.startsWith(request.getContextPath() + "/private/") && request.getRemoteUser() == null) {
            String doLoginPath = request.getContextPath() + "/login" + "?initialURI=" + request.getRequestURI();
            response.sendRedirect(response.encodeRedirectURL(doLoginPath));
            return true;
        }

        SiteKey siteKey = SiteKey.portal(requestSiteName);
        String uri = requestPath;
View Full Code Here

            url.setQueryParameterValues(parameter, request.getParameterValues(parameter));
        }

        String s = url.toString();

        response.sendRedirect(response.encodeRedirectURL(s));
        return true;
    }

    @Override
    protected boolean getRequiresLifeCycle() {
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.