Class SessionCookieConfigImpl

  • All Implemented Interfaces:
    jakarta.servlet.SessionCookieConfig
    Direct Known Subclasses:
    WebSessionCookieConfig

    public class SessionCookieConfigImpl
    extends Object
    implements jakarta.servlet.SessionCookieConfig
    Class that may be used to configure various properties of cookies used for session tracking purposes.
    • Constructor Detail

      • SessionCookieConfigImpl

        public SessionCookieConfigImpl​(StandardContext ctx)
        Constructor
    • Method Detail

      • setName

        public void setName​(String name)
        Specified by:
        setName in interface jakarta.servlet.SessionCookieConfig
        Parameters:
        name - the cookie name to use
        Throws:
        IllegalStateException - if the ServletContext from which this SessionCookieConfig was acquired has already been initialized
      • setDomain

        public void setDomain​(String domain)
        Specified by:
        setDomain in interface jakarta.servlet.SessionCookieConfig
        Parameters:
        domain - the cookie domain to use
        Throws:
        IllegalStateException - if the ServletContext from which this SessionCookieConfig was acquired has already been initialized
      • setPath

        public void setPath​(String path)
        Specified by:
        setPath in interface jakarta.servlet.SessionCookieConfig
        Parameters:
        path - the cookie path to use
        Throws:
        IllegalStateException - if the ServletContext from which this SessionCookieConfig was acquired has already been initialized
      • getPath

        public String getPath()
        Specified by:
        getPath in interface jakarta.servlet.SessionCookieConfig
        Returns:
        the cookie path set via setPath(java.lang.String), or the context path of the ServletContext from which this SessionCookieConfig was acquired if setPath(java.lang.String) was never called
      • setComment

        @Deprecated
        public void setComment​(String comment)
        Deprecated.
        Specified by:
        setComment in interface jakarta.servlet.SessionCookieConfig
        Parameters:
        comment - the cookie comment to use
        Throws:
        IllegalStateException - if the ServletContext from which this SessionCookieConfig was acquired has already been initialized
      • setHttpOnly

        public void setHttpOnly​(boolean httpOnly)
        Specified by:
        setHttpOnly in interface jakarta.servlet.SessionCookieConfig
        Parameters:
        httpOnly - true if the session tracking cookies created on behalf of the ServletContext from which this SessionCookieConfig was acquired shall be marked as HttpOnly, false otherwise
        Throws:
        IllegalStateException - if the ServletContext from which this SessionCookieConfig was acquired has already been initialized
      • isHttpOnly

        public boolean isHttpOnly()
        Specified by:
        isHttpOnly in interface jakarta.servlet.SessionCookieConfig
        Returns:
        true if the session tracking cookies created on behalf of the ServletContext from which this SessionCookieConfig was acquired will be marked as HttpOnly, false otherwise
      • setSecure

        public void setSecure​(boolean secure)
        Specified by:
        setSecure in interface jakarta.servlet.SessionCookieConfig
        Parameters:
        secure - true if the session tracking cookies created on behalf of the ServletContext from which this SessionCookieConfig was acquired shall be marked as secure even if the request that initiated the corresponding session is using plain HTTP instead of HTTPS, and false if they shall be marked as secure only if the request that initiated the corresponding session was also secure
        Throws:
        IllegalStateException - if the ServletContext from which this SessionCookieConfig was acquired has already been initialized
      • isSecure

        public boolean isSecure()
        Specified by:
        isSecure in interface jakarta.servlet.SessionCookieConfig
        Returns:
        true if the session tracking cookies created on behalf of the ServletContext from which this SessionCookieConfig was acquired will be marked as secure even if the request that initiated the corresponding session is using plain HTTP instead of HTTPS, and false if they will be marked as secure only if the request that initiated the corresponding session was also secure
      • setMaxAge

        public void setMaxAge​(int maxAge)
        Specified by:
        setMaxAge in interface jakarta.servlet.SessionCookieConfig
      • getMaxAge

        public int getMaxAge()
        Specified by:
        getMaxAge in interface jakarta.servlet.SessionCookieConfig
      • setAttribute

        public void setAttribute​(String name,
                                 String value)
        Sets the value for the given session cookie attribute.
        Specified by:
        setAttribute in interface jakarta.servlet.SessionCookieConfig
        Parameters:
        name - Name of attribute to set, case insensitive
        value - Value of attribute
        Throws:
        IllegalStateException - if the associated ServletContext has already been initialized
        IllegalArgumentException - If the attribute name is null or contains any characters not permitted for use in Cookie names.
        NumberFormatException - If the attribute is known to be numerical but the provided value cannot be parsed to a number.
      • getAttribute

        public String getAttribute​(String name)
        Get the value for a given session cookie attribute.
        Specified by:
        getAttribute in interface jakarta.servlet.SessionCookieConfig
        Parameters:
        name - Name of attribute
        Returns:
        Value of specified attribute
      • getAttributes

        public Map<String,​String> getAttributes()
        Get all the session cookie attributes in case insensitive order
        Specified by:
        getAttributes in interface jakarta.servlet.SessionCookieConfig
        Returns:
        A read-only Map of attributes.