Class CookieUtils


  • public class CookieUtils
    extends Object
    • Constructor Detail

      • CookieUtils

        public CookieUtils()
    • Method Detail

      • getParameterValue

        public static final String getParameterValue​(javax.servlet.http.HttpServletRequest request,
                                                     String name)
        Returns the value of a request parameter, or if not found tries to find a cookie with the same name.
        Parameters:
        request - the HTTP request
        name - the parameter name
        Returns:
        the value (never null, may be empty)
      • setCookie

        public static final void setCookie​(javax.servlet.http.HttpServletResponse response,
                                           String name,
                                           String value,
                                           CookieUtils.Lifespan lifeSpan)
        Set a cookie on the client.
        Parameters:
        response - the HTTP response wrapper
        name - the cookie name
        value - the cookie value
        lifeSpan - the cookie TTL as an CookieUtils.Lifespan enum value
      • setCookie

        public static final void setCookie​(javax.servlet.http.HttpServletResponse response,
                                           String name,
                                           String value)
        Set a cookie on the client, with a default lifespan of @see Lifespan#HOUR
        Parameters:
        response - the HTTP response wrapper
        name - the cookie name
        value - the cookie value