Immediate Subinterfaces: None
Implemented By: None
Availability: Servlet API 2.0 and later
HttpSession interface provides a mechanism for
holding temporary information about visitors to a web site. For a
detailed introduction to session tracking, see Chapter 7. The
itself allows servlets to view and manipulate session-specific
information, such as creation time and the unique session identifier.
It also includes methods to bind objects to the session for later
retrieval, allowing “shopping cart” and other
applications to hold onto data between client requests.
A servlet obtains an
HttpSession object from the
getSession( ) method of
HttpServletRequest. Session behavior, such as the
amount of idle time before a session is destroyed, can be configured
programmatically and via the web application deployment descriptor.
For sessions inside a nondistributed web application, any object may
be bound to the session. Objects that implement
java.io.Serializable may be written to disk to
save memory and to persist between server restarts.
For sessions inside a distributed web application, objects placed
into the session must implement
java.io.Serializable. The server may throw an
IllegalArgumentException when this requirement is
not met. Servers use session affinity to efficiently manage sessions in a distributed environment where there are multiple backend servers. This ...