Skip to Main Content
Java Servlet Programming
book

Java Servlet Programming

by Jason Hunter
November 1998
Intermediate to advanced content levelIntermediate to advanced
526 pages
14h 38m
English
O'Reilly Media, Inc.
Content preview from Java Servlet Programming

Name

HttpSessionContext

Synopsis

Interface Name: javax.servlet.http.HttpSessionContext

Superinterface: None

Immediate Subinterfaces: None

Implemented By: None

Availability: New as of the Servlet API 2.0; found in JSDK 2.0, JWS 1.1

Description

HttpSessionContext provides access to all of the currently active sessions on the server. This can be useful for servlets that weed out inactive sessions, display statistics, or otherwise share information. A servlet obtains an HttpSessionContext object from the getSessionContext() method of HttpSession.

Interface Declaration

public interface HttpSessionContext { 
  // Methods
  public abstract Enumeration getIds();
  public abstract HttpSession getSession(String sessionId);
}

Methods

getIds()

public abstract Enumeration getIds()
Description

Returns an Enumeration that contains the session IDs for all the currently valid sessions in this context. It returns an empty Enumeration if there are no valid sessions. The session IDs returned by getIds() should be held as a server secret because any client with knowledge of another client’s session ID can, with a forged cookie or URL, join the second client’s session.

getSession()

public abstract HttpSession getSession(String sessionId)
Description

Returns the session associated with the given session identifier. A list of valid session IDs can be obtained from the getIds() method.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Servlet Programming, 2nd Edition

Java Servlet Programming, 2nd Edition

Jason Hunter, William Crawford

Publisher Resources

ISBN: 156592391XSupplemental ContentCatalog PageErrata