Name

session

Synopsis

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

Interface Declarations

public interface HttpSession {

  public Object getAttribute(String name);
  public java.util.Enumeration getAttributeNames( );
  public long getCreationTime( );
  public String getId( );
  public long getLastAccessedTime( );
  public int getMaxInactiveInterval( );
  public void invalidate( );
  public boolean isNew( );
  public void removeAttribute(String name);
  public void setAttribute(String name, Object attribute);
  public void setMaxInactiveInterval(int interval);

  // Deprecated methods
  public HttpSessionContext getSessionContext( );
  public Object getValue(String name);
  public String[] getValueNames( );
  public void putValue(String name, Object value);
  public void removeValue(String name);
}

Methods

public Object getAttribute(String ...

Get Java Server Pages 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.