Name

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.

Methods

public Object getAttribute(String name)

Returns the Object associated with the specified name in this session, or null if the object is not found.

public java.util.Enumeration getAttributeNames()

Returns an Enumeration of String objects containing the names of all the objects in this session.

public long getCreationTime()

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

public String getId()

Returns a String containing the unique identifier assigned to this session.

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).

public int getMaxInactiveInterval() ...

Get JavaServer Pages Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.