Class DefaultRedirectStrategy

  • All Implemented Interfaces:
    RedirectStrategy

    public class DefaultRedirectStrategy
    extends java.lang.Object
    implements RedirectStrategy
    Simple implementation of RedirectStrategy which is the default used throughout the framework.
    Since:
    3.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.apache.commons.logging.Log logger  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.String calculateRedirectUrl​(java.lang.String contextPath, java.lang.String url)  
      protected boolean isContextRelative()
      Returns true, if the redirection URL should be calculated minus the protocol and context path (defaults to false).
      void sendRedirect​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String url)
      Redirects the response to the supplied URL.
      void setContextRelative​(boolean useRelativeContext)
      If true, causes any redirection URLs to be calculated minus the protocol and context path (defaults to false).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • logger

        protected final org.apache.commons.logging.Log logger
    • Constructor Detail

      • DefaultRedirectStrategy

        public DefaultRedirectStrategy()
    • Method Detail

      • sendRedirect

        public void sendRedirect​(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response,
                                 java.lang.String url)
                          throws java.io.IOException
        Redirects the response to the supplied URL.

        If contextRelative 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.

        Specified by:
        sendRedirect in interface RedirectStrategy
        Parameters:
        request - the current request
        response - the response to redirect
        url - the target URL to redirect to, for example "/login"
        Throws:
        java.io.IOException
      • calculateRedirectUrl

        protected java.lang.String calculateRedirectUrl​(java.lang.String contextPath,
                                                        java.lang.String url)
      • setContextRelative

        public void setContextRelative​(boolean useRelativeContext)
        If true, causes any redirection URLs to be calculated minus the protocol and context path (defaults to false).
      • isContextRelative

        protected boolean isContextRelative()
        Returns true, if the redirection URL should be calculated minus the protocol and context path (defaults to false).