Class ServletUtil


  • public class ServletUtil
    extends java.lang.Object
    Contains Servlet-related utilities.
    Since:
    6.0.0
    Version:
    $Revision: 24678 $ $Date: 2021-08-21 22:28:26 -0300 (Sat, 21 Aug 2021) $
    • Constructor Detail

      • ServletUtil

        public ServletUtil()
    • Method Detail

      • getApplicationRequestedPath

        public static java.lang.String getApplicationRequestedPath​(HttpServletRequest request)
        Returns the requested path, relative to the web application root. This path starts with '/'. Does not include the query string.
        Parameters:
        request - the http servlet request.
        Returns:
        the path.
        Since:
        6.0.0
      • getQueryStringParameter

        public static java.lang.String getQueryStringParameter​(HttpServletRequest request,
                                                               java.lang.String parameterName)
        Tries to read a request parameter from its query string. If the parameter has multiple values, any of them may be returned.
        Parameters:
        request - the request.
        parameterName - the parameter name.
        Returns:
        the parameter value, or null if it was not found.
        Since:
        8.0.0
      • clearQueryStringParameters

        public static void clearQueryStringParameters​(HttpServletRequest request)
        Removes cached query string parameters (if any).
        Parameters:
        request - the request
        Since:
        14.0.0
      • sendMovedPermanentlyWithNoCache

        public static void sendMovedPermanentlyWithNoCache​(HttpServletResponse response,
                                                           java.lang.String location)
        Sends a HttpServletResponse.SC_MOVED_PERMANENTLY status with a no-cache header.

        The 301 moved permanently HTTP response is cached by default. This method is a utility to send this type of response with caching disabled.

        Parameters:
        response - the response to send the status.
        location - the location to set in the response.
        Since:
        10.0.0
      • getSessionMutex

        public static java.lang.Object getSessionMutex​(HttpSession session)
        Return the object to synchronize on for the given session.
        Parameters:
        session - the session.
        Returns:
        the mutex object.