Interface SessionCookieConfig


  • public interface SessionCookieConfig
    Configures the session cookies used by the web application associated with the ServletContext from which this SessionCookieConfig was obtained.
    Since:
    Servlet 3.0
    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      java.lang.String getAttribute​(java.lang.String name)
      Obtain the value for a sesison cookie given attribute.
      java.util.Map<java.lang.String,​java.lang.String> getAttributes()
      Obtain the Map of attributes and values (excluding version) for this session cookie.
      java.lang.String getComment()
      Deprecated, for removal: This API element is subject to removal in a future version.
      This is no longer required with RFC 6265
      java.lang.String getDomain()
      Obtain the domain to use for session cookies.
      int getMaxAge()
      Obtain the maximum age to set for a session cookie.
      java.lang.String getName()
      Obtain the name to use for the session cookies.
      java.lang.String getPath()
      Obtain the path to use for session cookies.
      boolean isHttpOnly()
      Will session cookies be created with the httpOnly flag set?
      boolean isSecure()
      Will session cookies be created with the secure flag set?
      void setAttribute​(java.lang.String name, java.lang.String value)
      Sets the value for the given session cookie attribute.
      void setComment​(java.lang.String comment)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This is no longer required with RFC 6265
      void setDomain​(java.lang.String domain)
      Sets the domain for the session cookie
      void setHttpOnly​(boolean httpOnly)
      Sets the httpOnly flag for the session cookie.
      void setMaxAge​(int MaxAge)
      Sets the maximum age.
      void setName​(java.lang.String name)
      Sets the session cookie name.
      void setPath​(java.lang.String path)
      Sets the path of the session cookie.
      void setSecure​(boolean secure)
      Sets the secure flag for the session cookie.
    • Method Detail

      • setName

        void setName​(java.lang.String name)
        Sets the session cookie name.
        Parameters:
        name - The name of the session cookie
        Throws:
        java.lang.IllegalStateException - if the associated ServletContext has already been initialised
      • getName

        java.lang.String getName()
        Obtain the name to use for the session cookies.
        Returns:
        the name to use for session cookies.
      • setDomain

        void setDomain​(java.lang.String domain)
        Sets the domain for the session cookie
        Parameters:
        domain - The session cookie domain
        Throws:
        java.lang.IllegalStateException - if the associated ServletContext has already been initialised
      • getDomain

        java.lang.String getDomain()
        Obtain the domain to use for session cookies.
        Returns:
        the domain to use for session cookies.
      • setPath

        void setPath​(java.lang.String path)
        Sets the path of the session cookie.
        Parameters:
        path - The session cookie path
        Throws:
        java.lang.IllegalStateException - if the associated ServletContext has already been initialised
      • getPath

        java.lang.String getPath()
        Obtain the path to use for session cookies. This is normally the context path.
        Returns:
        The path to use for session cookies.
      • setComment

        @Deprecated(since="Servlet 6.0",
                    forRemoval=true)
        void setComment​(java.lang.String comment)
        Deprecated, for removal: This API element is subject to removal in a future version.
        This is no longer required with RFC 6265
        If called, this method has no effect.
        Parameters:
        comment - Ignore
        Throws:
        java.lang.IllegalStateException - if the associated ServletContext has already been initialised
      • getComment

        @Deprecated(since="Servlet 6.0",
                    forRemoval=true)
        java.lang.String getComment()
        Deprecated, for removal: This API element is subject to removal in a future version.
        This is no longer required with RFC 6265
        With the adoption of support for RFC 6265, this method should no longer be used.
        Returns:
        always null
      • setHttpOnly

        void setHttpOnly​(boolean httpOnly)
        Sets the httpOnly flag for the session cookie.
        Parameters:
        httpOnly - The httpOnly setting to use for session cookies
        Throws:
        java.lang.IllegalStateException - if the associated ServletContext has already been initialised
      • isHttpOnly

        boolean isHttpOnly()
        Will session cookies be created with the httpOnly flag set?
        Returns:
        true if the flag should be set, otherwise false
      • setSecure

        void setSecure​(boolean secure)
        Sets the secure flag for the session cookie.
        Parameters:
        secure - The secure setting to use for session cookies
        Throws:
        java.lang.IllegalStateException - if the associated ServletContext has already been initialised
      • isSecure

        boolean isSecure()
        Will session cookies be created with the secure flag set?
        Returns:
        true if the flag should be set, otherwise false
      • setMaxAge

        void setMaxAge​(int MaxAge)
        Sets the maximum age.
        Parameters:
        MaxAge - the maximum age to set
        Throws:
        java.lang.IllegalStateException - if the associated ServletContext has already been initialised
      • getMaxAge

        int getMaxAge()
        Obtain the maximum age to set for a session cookie.
        Returns:
        the maximum age in seconds
      • setAttribute

        void setAttribute​(java.lang.String name,
                          java.lang.String value)
        Sets the value for the given session cookie attribute. When a value is set via this method, the value returned by the attribute specific getter (if any) must be consistent with the value set via this method.
        Parameters:
        name - Name of attribute to set
        value - Value of attribute
        Throws:
        java.lang.IllegalStateException - if the associated ServletContext has already been initialised
        java.lang.IllegalArgumentException - If the attribute name is null or contains any characters not permitted for use in Cookie names.
        java.lang.NumberFormatException - If the attribute is known to be numerical but the provided value cannot be parsed to a number.
        Since:
        Servlet 6.0
      • getAttribute

        java.lang.String getAttribute​(java.lang.String name)
        Obtain the value for a sesison cookie given attribute. Values returned from this method must be consistent with the values set and returned by the attribute specific getters and setters in this class.
        Parameters:
        name - Name of attribute to return
        Returns:
        Value of specified attribute
        Since:
        Servlet 6.0
      • getAttributes

        java.util.Map<java.lang.String,​java.lang.String> getAttributes()
        Obtain the Map of attributes and values (excluding version) for this session cookie.
        Returns:
        A read-only Map of attributes to values, excluding version.
        Since:
        Servlet 6.0