Package spark
Class Session
java.lang.Object
spark.Session
Provides session information.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> T
Returns the object bound with the specified name in this session, or null if no object is bound under the name.void
Binds an object to this session, using the name specified.long
id()
void
Invalidates this session then unbinds any objects bound to it.boolean
isNew()
long
int
void
maxInactiveInterval
(int interval) Specifies the time, in seconds, between client requests the web container will invalidate this session.javax.servlet.http.HttpSession
raw()
void
removeAttribute
(String name) Removes the object bound with the specified name from this session.
-
Field Details
-
request
-
session
private final javax.servlet.http.HttpSession session
-
-
Constructor Details
-
Session
Session(javax.servlet.http.HttpSession session, Request request) Creates a session with theHttpSession
.- Parameters:
session
-request
-- Throws:
IllegalArgumentException
- If the session or the request is null.
-
-
Method Details
-
raw
public javax.servlet.http.HttpSession raw()- Returns:
- the raw
HttpSession
object handed in by the servlet container.
-
attribute
Returns the object bound with the specified name in this session, or null if no object is bound under the name.- Type Parameters:
T
- The type parameter- Parameters:
name
- a string specifying the name of the object- Returns:
- the object with the specified name
-
attribute
Binds an object to this session, using the name specified.- Parameters:
name
- the name to which the object is bound; cannot be nullvalue
- the object to be bound
-
attributes
- Returns:
- an
Enumeration
ofString
objects containing the names of all the objects bound to this session.
-
creationTime
public long creationTime()- Returns:
- the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.
-
id
- Returns:
- a string containing the unique identifier assigned to this session.
-
lastAccessedTime
public long lastAccessedTime()- 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.
-
maxInactiveInterval
public int maxInactiveInterval()- Returns:
- the maximum time interval, in seconds, that the container will keep this session open between client accesses.
-
maxInactiveInterval
public void maxInactiveInterval(int interval) Specifies the time, in seconds, between client requests the web container will invalidate this session.- Parameters:
interval
- the interval
-
invalidate
public void invalidate()Invalidates this session then unbinds any objects bound to it. -
isNew
public boolean isNew()- Returns:
- true if the client does not yet know about the session or if the client chooses not to join the session.
-
removeAttribute
Removes the object bound with the specified name from this session.- Parameters:
name
- the name of the object to remove from this session
-