Top Description Fields Methods
org.apache.catalina

public Interface Session

Known Direct Implementers
org.apache.catalina.manager.DummyProxySession, org.apache.catalina.session.StandardSession
Imports
java.security.Principal, java.util.Iterator, jakarta.servlet.http.HttpSession

A Session is the Catalina-internal facade for an HttpSession that is used to maintain state information between requests for a particular user of a web application.
Author
Craig R. McClanahan

Field Summary

Modifier and TypeField and Description
public static final String
SESSION_ACTIVATED_EVENT

The SessionEvent event type when a session is activated.

public static final String
SESSION_CREATED_EVENT

The SessionEvent event type when a session is created.

public static final String
SESSION_DESTROYED_EVENT

The SessionEvent event type when a session is destroyed.

public static final String
SESSION_PASSIVATED_EVENT

The SessionEvent event type when a session is passivated.

Method Summary

Modifier and TypeMethod and Description
public void
access()

Update the accessed time information for this session.

public void
addSessionListener(SessionListener
the SessionListener instance that should be notified for session events
listener
)

Add a session event listener to this component.

public void
endAccess()

End access to the session.

public void
expire()

Perform the internal processing required to invalidate this session, without triggering an exception if the session has already expired.

public String

Returns:

the authentication type used to authenticate our cached Principal, if any.
getAuthType
()

public long

Returns:

the creation time for this session.
getCreationTime
()

public long

Returns:

the creation time for this session, bypassing the session validity checks.
getCreationTimeInternal
()

public String

Returns:

the session identifier for this session.
getId
()

public String

Returns:

the session identifier for this session.
getIdInternal
()

public long

Returns:

the idle time (in milliseconds) from last client access time.
getIdleTime
()

public long

Returns:

the idle time from last client access time without invalidation check
getIdleTimeInternal
()

public long

Returns:

the last time the client sent a request associated with this session, as the number of milliseconds since midnight, January 1, 1970 GMT. Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time. This one gets updated whenever a request finishes.
getLastAccessedTime
()

public long

Returns:

the last client access time without invalidation check
getLastAccessedTimeInternal
()

public Manager

Returns:

the Manager within which this Session is valid.
getManager
()

public int

Returns:

the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session. A negative time indicates that the session should never time out.
getMaxInactiveInterval
()

public Object

Returns:

the object bound with the specified name to the internal notes for this session, or null if no such binding exists.
getNote
(String
Name of the note to be returned
name
)

public Iterator<String>

Returns:

an Iterator containing the String names of all notes bindings that exist for this session.
getNoteNames
()

public Principal

Returns:

the authenticated Principal that is associated with this Session. This provides an Authenticator with a means to cache a previously authenticated Principal, and avoid potentially expensive Realm.authenticate() calls on every request. If there is no current associated Principal, return null.
getPrincipal
()

public HttpSession

Returns:

the HttpSession for which this object is the facade.
getSession
()

public long

Returns:

the last time the client sent a request associated with this session, as the number of milliseconds since midnight, January 1, 1970 GMT. Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time. This one gets updated whenever a request starts.
getThisAccessedTime
()

public long

Returns:

the last client access time without invalidation check
getThisAccessedTimeInternal
()

public boolean

Returns:

true if distribution is supported, otherwise false
isAttributeDistributable
(String
The attribute name
name
,
Object
The attribute value
value
)

Does the session implementation support the distributing of the given attribute?

public boolean

Returns:

true if the session is still valid
isValid
()

public void
recycle()

Release all object references, and initialize instance variables, in preparation for reuse of this object.

public void
removeNote(String
Name of the note to be removed
name
)

Remove any object bound to the specified name in the internal notes for this session.

public void
removeSessionListener(SessionListener
remove the session listener, which will no longer be notified
listener
)

Remove a session event listener from this component.

public void
setAuthType(String
The new cached authentication type
authType
)

Set the authentication type used to authenticate our cached Principal, if any.

public void
setCreationTime(long
The new creation time
time
)

Set the creation time for this session.

public void
setId(String
The new session identifier
id
)

Set the session identifier for this session and notifies any associated listeners that a new session has been created.

public void
setId(String
The new session identifier
id
,
boolean
Should any associated listeners be notified that a new session has been created?
notify
)

Set the session identifier for this session and optionally notifies any associated listeners that a new session has been created.

public void
setManager(Manager
The new Manager
manager
)

Set the Manager within which this Session is valid.

public void
setMaxInactiveInterval(int
The new maximum interval
interval
)

Set the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session.

public void
setNew(boolean
The new value for the isNew flag
isNew
)

Set the isNew flag for this session.

public void
setNote(String
Name to which the object should be bound
name
,
Object
Object to be bound to the specified name
value
)

Bind an object to a specified name in the internal notes associated with this session, replacing any existing binding for this name.

public void
setPrincipal(Principal
The new Principal, or null if none
principal
)

Set the authenticated Principal that is associated with this Session.

public void
setValid(boolean
The new value for the isValid flag
isValid
)

Set the isValid flag for this session.

public void
tellChangedSessionId(String
new session ID
newId
,
String
old session ID
oldId
,
boolean
Should any associated sessionListeners be notified that session ID has been changed?
notifySessionListeners
,
boolean
Should any associated ContainerListeners be notified that session ID has been changed?
notifyContainerListeners
)

Inform the listeners about the change session ID.

Field Detail

SESSION_ACTIVATED_EVENTback to summary
public static final String SESSION_ACTIVATED_EVENT

The SessionEvent event type when a session is activated.

SESSION_CREATED_EVENTback to summary
public static final String SESSION_CREATED_EVENT

The SessionEvent event type when a session is created.

SESSION_DESTROYED_EVENTback to summary
public static final String SESSION_DESTROYED_EVENT

The SessionEvent event type when a session is destroyed.

SESSION_PASSIVATED_EVENTback to summary
public static final String SESSION_PASSIVATED_EVENT

The SessionEvent event type when a session is passivated.

Method Detail

accessback to summary
public void access()

Update the accessed time information for this session. This method should be called by the context when a request comes in for a particular session, even if the application does not reference it.

addSessionListenerback to summary
public void addSessionListener(SessionListener listener)

Add a session event listener to this component.

Parameters
listener:SessionListener

the SessionListener instance that should be notified for session events

endAccessback to summary
public void endAccess()

End access to the session.

expireback to summary
public void expire()

Perform the internal processing required to invalidate this session, without triggering an exception if the session has already expired.

getAuthTypeback to summary
public String getAuthType()
Returns:String

the authentication type used to authenticate our cached Principal, if any.

getCreationTimeback to summary
public long getCreationTime()
Returns:long

the creation time for this session.

getCreationTimeInternalback to summary
public long getCreationTimeInternal()
Returns:long

the creation time for this session, bypassing the session validity checks.

getIdback to summary
public String getId()
Returns:String

the session identifier for this session.

getIdInternalback to summary
public String getIdInternal()
Returns:String

the session identifier for this session.

getIdleTimeback to summary
public long getIdleTime()
Returns:long

the idle time (in milliseconds) from last client access time.

getIdleTimeInternalback to summary
public long getIdleTimeInternal()
Returns:long

the idle time from last client access time without invalidation check

See Also
getIdleTime()
getLastAccessedTimeback to summary
public long getLastAccessedTime()
Returns:long

the last time the client sent a request associated with this session, as the number of milliseconds since midnight, January 1, 1970 GMT. Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time. This one gets updated whenever a request finishes.

getLastAccessedTimeInternalback to summary
public long getLastAccessedTimeInternal()
Returns:long

the last client access time without invalidation check

See Also
getLastAccessedTime()
getManagerback to summary
public Manager getManager()
Returns:Manager

the Manager within which this Session is valid.

getMaxInactiveIntervalback to summary
public int getMaxInactiveInterval()
Returns:int

the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session. A negative time indicates that the session should never time out.

getNoteback to summary
public Object getNote(String name)
Parameters
name:String

Name of the note to be returned

Returns:Object

the object bound with the specified name to the internal notes for this session, or null if no such binding exists.

getNoteNamesback to summary
public Iterator<String> getNoteNames()
Returns:Iterator<String>

an Iterator containing the String names of all notes bindings that exist for this session.

getPrincipalback to summary
public Principal getPrincipal()
Returns:Principal

the authenticated Principal that is associated with this Session. This provides an Authenticator with a means to cache a previously authenticated Principal, and avoid potentially expensive Realm.authenticate() calls on every request. If there is no current associated Principal, return null.

getSessionback to summary
public HttpSession getSession()
Returns:HttpSession

the HttpSession for which this object is the facade.

getThisAccessedTimeback to summary
public long getThisAccessedTime()
Returns:long

the last time the client sent a request associated with this session, as the number of milliseconds since midnight, January 1, 1970 GMT. Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time. This one gets updated whenever a request starts.

getThisAccessedTimeInternalback to summary
public long getThisAccessedTimeInternal()
Returns:long

the last client access time without invalidation check

See Also
getThisAccessedTime()
isAttributeDistributableback to summary
public boolean isAttributeDistributable(String name, Object value)

Does the session implementation support the distributing of the given attribute? If the Manager is marked as distributable, then this method must be used to check attributes before adding them to a session and an IllegalArgumentException thrown if the proposed attribute is not distributable.

Note that the Manager implementation may further restrict which attributes are distributed but a Manager level restriction should not trigger an IllegalArgumentException in HttpSession#setAttribute(String, Object)

Parameters
name:String

The attribute name

value:Object

The attribute value

Returns:boolean

true if distribution is supported, otherwise false

isValidback to summary
public boolean isValid()
Returns:boolean

true if the session is still valid

recycleback to summary
public void recycle()

Release all object references, and initialize instance variables, in preparation for reuse of this object.

removeNoteback to summary
public void removeNote(String name)

Remove any object bound to the specified name in the internal notes for this session.

Parameters
name:String

Name of the note to be removed

removeSessionListenerback to summary
public void removeSessionListener(SessionListener listener)

Remove a session event listener from this component.

Parameters
listener:SessionListener

remove the session listener, which will no longer be notified

setAuthTypeback to summary
public void setAuthType(String authType)

Set the authentication type used to authenticate our cached Principal, if any.

Parameters
authType:String

The new cached authentication type

setCreationTimeback to summary
public void setCreationTime(long time)

Set the creation time for this session. This method is called by the Manager when an existing Session instance is reused.

Parameters
time:long

The new creation time

setIdback to summary
public void setId(String id)

Set the session identifier for this session and notifies any associated listeners that a new session has been created.

Parameters
id:String

The new session identifier

setIdback to summary
public void setId(String id, boolean notify)

Set the session identifier for this session and optionally notifies any associated listeners that a new session has been created.

Parameters
id:String

The new session identifier

notify:boolean

Should any associated listeners be notified that a new session has been created?

setManagerback to summary
public void setManager(Manager manager)

Set the Manager within which this Session is valid.

Parameters
manager:Manager

The new Manager

setMaxInactiveIntervalback to summary
public void setMaxInactiveInterval(int interval)

Set the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session. A negative time indicates that the session should never time out.

Parameters
interval:int

The new maximum interval

setNewback to summary
public void setNew(boolean isNew)

Set the isNew flag for this session.

Parameters
isNew:boolean

The new value for the isNew flag

setNoteback to summary
public void setNote(String name, Object value)

Bind an object to a specified name in the internal notes associated with this session, replacing any existing binding for this name.

Parameters
name:String

Name to which the object should be bound

value:Object

Object to be bound to the specified name

setPrincipalback to summary
public void setPrincipal(Principal principal)

Set the authenticated Principal that is associated with this Session. This provides an Authenticator with a means to cache a previously authenticated Principal, and avoid potentially expensive Realm.authenticate() calls on every request.

Parameters
principal:Principal

The new Principal, or null if none

setValidback to summary
public void setValid(boolean isValid)

Set the isValid flag for this session.

Parameters
isValid:boolean

The new value for the isValid flag

tellChangedSessionIdback to summary
public void tellChangedSessionId(String newId, String oldId, boolean notifySessionListeners, boolean notifyContainerListeners)

Inform the listeners about the change session ID.

Parameters
newId:String

new session ID

oldId:String

old session ID

notifySessionListeners:boolean

Should any associated sessionListeners be notified that session ID has been changed?

notifyContainerListeners:boolean

Should any associated ContainerListeners be notified that session ID has been changed?