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 emptyEnumeration
if there are no valid sessions. The session IDs returned bygetIds()
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.
Get Java Servlet Programming 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.