session |
Variable name:
session
Interface name:
javax.servlet.http.HttpSession
Extends:
None
Implemented by:
Internal container-dependent class
JSP page type:
Available in both regular JSP pages and error pages, unless the page directive session attribute is set to false
Description
The session variable is assigned a reference to the HttpSession object that represents the current client session. Information stored as HttpSession attributes corresponds to objects in the JSP session scope. By default, the session persists for the time period specified in the web application deployment descriptor, across more than one page request from the user. The container can maintain a session in many ways, such as using cookies or rewriting URLs.

getAttribute() |
public Object getAttribute(String name)
Returns the Object associated with the specified name in this session, or null if the object is not found.

getAttributeNames() |
public java.util.Enumeration getAttributeNames()
Returns an Enumeration of String objects containing the names of all the objects in this session.

getCreationTime() |
public long getCreationTime()
Returns the time when this session was created, measured in milliseconds since the epoch ( January 1, 1970, 00:00:00 GMT).

getId() |
public String getId()
Returns a String containing the unique identifier assigned to this session.

getLastAccessedTime() |
public long getLastAccessedTime()
Returns the last time the client sent a request associated with this session as the number of milliseconds since the epoch ( January 1, 1970, 00:00:00 GMT).

getMaxInactiveInterval() |
public int getMaxInactiveInterval()
Returns the maximum time interval, in seconds, that the servlet container will keep this session active between client accesses.

invalidate() |
public void invalidate()
Invalidates this session and unbinds any objects bound to it, calling the valueUnbound() methods of all objects in the session implementing the HttpSessionBindingListener interface.

isNew() |
public boolean isNew()
Returns true if a request for this session has not yet been received from the client.

removeAttribute() |
public void removeAttribute(String name)
Removes the object bound with the specified name from this session.

setAttribute() |
public void setAttribute(String name, Object attribute)
Associates the specified object with this session using the name specified.

setMaxInactiveInterval() |
public void setMaxInactiveInterval(int interval)
Specifies the time, in seconds, that can elapse between client requests before the servlet container will invalidate this session.

getSessionContext() | Deprecated
public HttpSessionContext getSessionContext()
As of the Servlet 2.1 API, this method is deprecated and has no replacement.

getValue() | Deprecated
public Object getValue(String name)
As of the Servlet 2.2 API, this method is replaced by getAttribute(String).

getValueNames() | Deprecated
public String[] getValueNames()
As of the Servlet 2.2 API, this method is replaced by getAttributeNames().

putValue() | Deprecated
public void putValue(String name, Object value)
As of the Servlet 2.2 API, this method is replaced by setAttribute(String, Object).

removeValue() | Deprecated
public void removeValue(String name)
As of the Servlet 2.2 API, this method is replaced by setAttribute(String, Object).