Class RedirectUtils


  • public class RedirectUtils
    extends Object
    Provides utility methods related to HTTP redirect.
    Since:
    3.6.5
    • Field Detail

      • REDIRECT_CONTENT_PATTERN

        public static final String REDIRECT_CONTENT_PATTERN
        The pattern containing the alternative redirect instructions into which the location will be substituted
        See Also:
        Constant Field Values
    • Constructor Detail

      • RedirectUtils

        public RedirectUtils()
    • Method Detail

      • storeSessionEntryUrl

        public static String storeSessionEntryUrl​(HttpServletRequest request)
        Stores the Entry URL in the session for SSO integration support.
        Parameters:
        request - the servlet request (required)
        Returns:
        the stored URL stored in the session
        Since:
        4.0.0
      • getSessionEntryUrl

        public static String getSessionEntryUrl​(HttpServletRequest request)
        Return the session stored Entry URL for SSO integration support.
        Parameters:
        request - the servlet request (required)
        Returns:
        the Entry URL if available or null otherwise
        Since:
        4.0.0
      • evaluateRedirect

        public static boolean evaluateRedirect​(String location,
                                               HttpServletRequest request)
        See if the current user needs custom redirect behavior. Whether an alternative redirect is required is determined by matching the user-agent header against the value of the deployment property DeploymentProperty.PROPERTY_ALTERNATIVE_REDIRECT_USER_AGENTS. Note: If location is empty, this method returns true. This is to support special cases in Click, where setRedirect(null) is called in certain onDestroy handlers. The standard method Page.setRedirect(String, java.util.Map) includes handling of null locations.
        Parameters:
        location - the location to redirect to (optional)
        request - the HTTP servlet request (required)
        Returns:
        true if a "normal" redirect should be performed; false if an alternative redirect method should be used (the caller can elect to use performRefreshRedirect(String, Map, HttpServletRequest, HttpServletResponse))
      • performRedirect

        public static void performRedirect​(String location,
                                           Map<String,​?> params,
                                           HttpServletRequest request,
                                           HttpServletResponse response)
        Performs a standard redirect.
        Parameters:
        location - the location to redirect to (required)
        params - the map of request parameters
        response - the HTTP servlet response (required)
      • performRefreshRedirect

        public static void performRefreshRedirect​(String location,
                                                  Map<String,​?> params,
                                                  HttpServletRequest request,
                                                  HttpServletResponse response)
        Performs an alternative redirect. This can be necessary if standard HTTP redirects are not supported (e.g. Android stock browser 4.2)
        Parameters:
        location - the location to redirect to (required)
        params - the map of request parameters
        request - the HTTP servlet request (required)
        response - the HTTP servlet response (required)