Name

session

Synopsis

The session variable is assigned a reference to the HttpSession object that represents the current client’s session. Information stored as HttpSession attributes corresponds to objects in the JSP session scope.

By default, the session persists for a 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.

Synopsis

Variable name:

session

EL expression

${pageContext.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

Methods

public Object getAttribute(String name)

Returns the object associated d the specified name in this session or null if the object isn’t 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 midnight January 1, 1970 GMT.

public String getId( )

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

public long getLastAccessedTime( )

Returns the time for the previous request associated with this session as the number of milliseconds since midnight ...

Get JavaServer Pages, Second Edition 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.