public interface Session
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
getAttribute(java.lang.String name)
Returns the object bound with the specified name in this session, or
null if no object is bound under the
name. |
java.util.Enumeration<java.lang.String> |
getAttributeNames()
Returns an
Enumeration of String objects containing the names of all the objects bound to this
session. |
long |
getCreatedTime()
Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.
|
java.lang.String |
getId()
Returns a string containing the unique identifier assigned to this session.
|
long |
getLastAccessedTime()
Returns the last time the client sent a request associated with this session, as the number of milliseconds since
midnight January 1, 1970 GMT, and marked by the time the container received the request.
|
int |
getMaxInactiveInterval()
Returns the maximum time interval, in seconds, that the server will keep this session open between client
accesses.
|
void |
invalidate()
Invalidates this session then unbinds any objects bound to it.
|
boolean |
isNew()
Returns
true if the client does not yet know about the session or if the client chooses not to join the
session. |
boolean |
isValid() |
void |
removeAttribute(java.lang.String name)
Removes the object bound with the specified name from this session.
|
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Binds an object to this session, using the name specified.
|
void |
setMaxInactiveInterval(int interval)
Specifies the time, in seconds, between client requests before the server will invalidate this session.
|
java.lang.String getId()
long getCreatedTime()
long getLastAccessedTime()
Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time.
void setMaxInactiveInterval(int interval)
An interval value of zero or less indicates that the session should never timeout.
interval - an integer specifying the number of seconds.int getMaxInactiveInterval()
setMaxInactiveInterval(int) method.
A return value of zero or less indicates that the session will never timeout.
java.lang.Object getAttribute(java.lang.String name)
null if no object is bound under the
name.name - a string specifying the name of the object.java.util.Enumeration<java.lang.String> getAttributeNames()
Enumeration of String objects containing the names of all the objects bound to this
session.void setAttribute(java.lang.String name,
java.lang.Object value)
If the value passed in is null, this has the same effect as calling removeAttribute(String).
name - the name to which the object is bound, cannot be null.value - the object to be bound.void removeAttribute(java.lang.String name)
name - the name of the object to remove from this session.void invalidate()
boolean isNew()
true if the client does not yet know about the session or if the client chooses not to join the
session. E.g. if the server used only cookie-based sessions, and the client had disabled the use of cookies, then
a session would be new on each request.true if the server has created a session, but the client has not yet joined.boolean isValid()
true is the session is valid, or false if the session is invalid.