Top Description Fields Constructors Methods
org.glassfish.grizzly.servlet

public Class SessionCookieConfig

extends Object
implements SessionCookieConfig
Class Inheritance
All Implemented Interfaces
jakarta.servlet.SessionCookieConfig
Imports
java.util.Collections, .Map, .TreeMap, org.glassfish.grizzly.http.server.Constants

Class that may be used to configure various properties of cookies used for session tracking purposes.

Field Summary

Modifier and TypeField and Description
private final Map<String, String>
private final WebappContext
private static final boolean
private static final int
private static final String
private static final boolean
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
getAttribute(String name)

Implements jakarta.servlet.SessionCookieConfig.getAttribute.

Obtain the value for a given session cookie attribute.

public Map<String, String>
getAttributes()

Implements jakarta.servlet.SessionCookieConfig.getAttributes.

Obtain the Map (keys are case insensitive) of all attributes and values, including those set via the attribute specific setters, (excluding version) for this SessionCookieConfig.

public String

Returns:

the cookie comment set via setComment, or null if setComment was never called
getComment
()

Implements jakarta.servlet.SessionCookieConfig.getComment.

Deprecated

With the adoption of support for RFC 6265, this method should no longer be used.

public String

Returns:

the cookie domain set via setDomain, or null if setDomain was never called
getDomain
()

Implements jakarta.servlet.SessionCookieConfig.getDomain.

Gets the domain name that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.

public int
getMaxAge()

Implements jakarta.servlet.SessionCookieConfig.getMaxAge.

Gets the lifetime (in seconds) of the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.

public String

Returns:

the cookie name set via setName, or JSESSIONID if setName was never called
getName
()

Implements jakarta.servlet.SessionCookieConfig.getName.

Gets the name that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.

public String

Returns:

the cookie path set via setPath, or the context path of the ServletContext from which this SessionCookieConfig was acquired if setPath was never called
getPath
()

Implements jakarta.servlet.SessionCookieConfig.getPath.

Gets the path that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.

public boolean

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
isHttpOnly
()

Implements jakarta.servlet.SessionCookieConfig.isHttpOnly.

Checks if the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired will be marked as HttpOnly.

public boolean

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
isSecure
()

Implements jakarta.servlet.SessionCookieConfig.isSecure.

Checks if the session tracking cookies created on behalf of the application represented by 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.

public void
setAttribute(String name, String value)

Implements jakarta.servlet.SessionCookieConfig.setAttribute.

Sets the value for the given session cookie attribute.

public void
setComment(String
the cookie comment to use
comment
)

Implements jakarta.servlet.SessionCookieConfig.setComment.

Deprecated

With the adoption of support for RFC 6265, this method should no longer be used.

public void
setDomain(String
the cookie domain to use
domain
)

Implements jakarta.servlet.SessionCookieConfig.setDomain.

Sets the domain name that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.

public void
setHttpOnly(boolean
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
httpOnly
)

Implements jakarta.servlet.SessionCookieConfig.setHttpOnly.

Marks or unmarks the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired as HttpOnly.

public void
setMaxAge(int maxAge)

Implements jakarta.servlet.SessionCookieConfig.setMaxAge.

Sets the lifetime (in seconds) for the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.

public void
setName(String
the cookie name to use
name
)

Implements jakarta.servlet.SessionCookieConfig.setName.

Sets the name that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.

public void
setPath(String
the cookie path to use
path
)

Implements jakarta.servlet.SessionCookieConfig.setPath.

Sets the path that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.

public void
setSecure(boolean
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
secure
)

Implements jakarta.servlet.SessionCookieConfig.setSecure.

Marks or unmarks the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired as secure.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributesback to summary
private final Map<String, String> attributes
ctxback to summary
private final WebappContext ctx
DEFAULT_HTTP_ONLYback to summary
private static final boolean DEFAULT_HTTP_ONLY
DEFAULT_MAX_AGEback to summary
private static final int DEFAULT_MAX_AGE
DEFAULT_NAMEback to summary
private static final String DEFAULT_NAME
DEFAULT_SECUREback to summary
private static final boolean DEFAULT_SECURE
nameback to summary
private String name

Constructor Detail

SessionCookieConfigback to summary
public SessionCookieConfig(WebappContext ctx)

Constructor

Method Detail

getAttributeback to summary
public String getAttribute(String name)

Implements jakarta.servlet.SessionCookieConfig.getAttribute.

Doc from jakarta.servlet.SessionCookieConfig.getAttribute.

Obtain the value for a given session cookie 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.

Annotations
@Override
getAttributesback to summary
public Map<String, String> getAttributes()

Implements jakarta.servlet.SessionCookieConfig.getAttributes.

Doc from jakarta.servlet.SessionCookieConfig.getAttributes.

Obtain the Map (keys are case insensitive) of all attributes and values, including those set via the attribute specific setters, (excluding version) for this SessionCookieConfig.

Annotations
@Override
getCommentback to summary
public String getComment()

Implements jakarta.servlet.SessionCookieConfig.getComment.

Doc from jakarta.servlet.SessionCookieConfig.getComment.

Deprecated

With the adoption of support for RFC 6265, this method should no longer be used.

Returns:String

the cookie comment set via setComment, or null if setComment was never called

Annotations
@Deprecated
@Override
getDomainback to summary
public String getDomain()

Implements jakarta.servlet.SessionCookieConfig.getDomain.

Doc from jakarta.servlet.SessionCookieConfig.getDomain.

Gets the domain name that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.

Returns:String

the cookie domain set via setDomain, or null if setDomain was never called

Annotations
@Override
getMaxAgeback to summary
public int getMaxAge()

Implements jakarta.servlet.SessionCookieConfig.getMaxAge.

Doc from jakarta.servlet.SessionCookieConfig.getMaxAge.

Gets the lifetime (in seconds) of the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.

By default, -1 is returned.

Annotations
@Override
getNameback to summary
public String getName()

Implements jakarta.servlet.SessionCookieConfig.getName.

Doc from jakarta.servlet.SessionCookieConfig.getName.

Gets the name that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.

By default, JSESSIONID will be used as the cookie name.

Returns:String

the cookie name set via setName, or JSESSIONID if setName was never called

Annotations
@Override
getPathback to summary
public String getPath()

Implements jakarta.servlet.SessionCookieConfig.getPath.

Doc from jakarta.servlet.SessionCookieConfig.getPath.

Gets the path that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.

By default, the context path of the ServletContext from which this SessionCookieConfig was acquired will be used.

Returns:String

the cookie path set via setPath, or the context path of the ServletContext from which this SessionCookieConfig was acquired if setPath was never called

Annotations
@Override
isHttpOnlyback to summary
public boolean isHttpOnly()

Implements jakarta.servlet.SessionCookieConfig.isHttpOnly.

Doc from jakarta.servlet.SessionCookieConfig.isHttpOnly.

Checks if the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired will be marked as HttpOnly.

Returns:boolean

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

Annotations
@Override
isSecureback to summary
public boolean isSecure()

Implements jakarta.servlet.SessionCookieConfig.isSecure.

Doc from jakarta.servlet.SessionCookieConfig.isSecure.

Checks if the session tracking cookies created on behalf of the application represented by 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.

Returns:boolean

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

Annotations
@Override
setAttributeback to summary
public void setAttribute(String name, String value)

Implements jakarta.servlet.SessionCookieConfig.setAttribute.

Doc from jakarta.servlet.SessionCookieConfig.setAttribute.

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.

Annotations
@Override
setCommentback to summary
public void setComment(String comment)

Implements jakarta.servlet.SessionCookieConfig.setComment.

Doc from jakarta.servlet.SessionCookieConfig.setComment.

Deprecated

With the adoption of support for RFC 6265, this method should no longer be used.

If called, this method has no effect.

Parameters
comment:String

the cookie comment to use

Annotations
@Deprecated
@Override
Exceptions
IllegalStateException:
if the ServletContext from which this SessionCookieConfig was acquired has already been initialized
setDomainback to summary
public void setDomain(String domain)

Implements jakarta.servlet.SessionCookieConfig.setDomain.

Doc from jakarta.servlet.SessionCookieConfig.setDomain.

Sets the domain name that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.

Parameters
domain:String

the cookie domain to use

Annotations
@Override
Exceptions
IllegalStateException:
if the ServletContext from which this SessionCookieConfig was acquired has already been initialized
setHttpOnlyback to summary
public void setHttpOnly(boolean httpOnly)

Implements jakarta.servlet.SessionCookieConfig.setHttpOnly.

Doc from jakarta.servlet.SessionCookieConfig.setHttpOnly.

Marks or unmarks the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired as HttpOnly.

A cookie is marked as HttpOnly by adding the HttpOnly attribute to it. HttpOnly cookies are not supposed to be exposed to client-side scripting code, and may therefore help mitigate certain kinds of cross-site scripting attacks.

Parameters
httpOnly:boolean

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

Annotations
@Override
Exceptions
IllegalStateException:
if the ServletContext from which this SessionCookieConfig was acquired has already been initialized
setMaxAgeback to summary
public void setMaxAge(int maxAge)

Implements jakarta.servlet.SessionCookieConfig.setMaxAge.

Doc from jakarta.servlet.SessionCookieConfig.setMaxAge.

Sets the lifetime (in seconds) for the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.

Annotations
@Override
setNameback to summary
public void setName(String name)

Implements jakarta.servlet.SessionCookieConfig.setName.

Doc from jakarta.servlet.SessionCookieConfig.setName.

Sets the name that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.

Note

Changing the name of session tracking cookies may break other tiers (for example, a load balancing frontend) that assume the cookie name to be equal to the default JSESSIONID, and therefore should only be done cautiously.

Parameters
name:String

the cookie name to use

Annotations
@Override
Exceptions
IllegalStateException:
if the ServletContext from which this SessionCookieConfig was acquired has already been initialized
setPathback to summary
public void setPath(String path)

Implements jakarta.servlet.SessionCookieConfig.setPath.

Doc from jakarta.servlet.SessionCookieConfig.setPath.

Sets the path that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.

Parameters
path:String

the cookie path to use

Annotations
@Override
Exceptions
IllegalStateException:
if the ServletContext from which this SessionCookieConfig was acquired has already been initialized
setSecureback to summary
public void setSecure(boolean secure)

Implements jakarta.servlet.SessionCookieConfig.setSecure.

Doc from jakarta.servlet.SessionCookieConfig.setSecure.

Marks or unmarks the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired as secure.

One use case for marking a session tracking cookie as secure, even though the request that initiated the session came over HTTP, is to support a topology where the web container is front-ended by an SSL offloading load balancer. In this case, the traffic between the client and the load balancer will be over HTTPS, whereas the traffic between the load balancer and the web container will be over HTTP.

Parameters
secure:boolean

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

Annotations
@Override
Exceptions
IllegalStateException:
if the ServletContext from which this SessionCookieConfig was acquired has already been initialized