SE452: The Session API [7/16] ![]() ![]() ![]() |
In the HttpServletRequest class:
HttpSession getSession() HttpSession getSession( boolean create)
Returns the current HttpSession associated with this request, or if there is no current session and create is true, returns a new session.
Default: create is true
String getRequestedSessionId()
Returns the session ID.
In the HttpServletResponse class:
String encodeURL( String url)
Encodes the specified URL by including the session ID in it, or If encoding is not needed, returns the URL unchanged.
The HttpSession class:
void setAttribute( String name,Object value)
Binds an object to the specified name in this session.
Object getAttribute( String name)
void removeAttribute( String name)
setAttribute(name, null);
String getId()
Returns the session ID.
Enumeration getAttributeNames()
Returns an Enumeration of string objects containing the names of all the objects bound to this session.
long getCreationTime()
Returns the time when this session was created in ms since the epoch
long getLastAccessedTime()
Returns the last time the client sent a request associated with this session.
int getMaxInactiveInterval()
void setMaxInactiveInterval( int interval)
void invalidate()
Invalidates this session and unbinds any objects in this session.
boolean isNew()