Name
HttpSession
Synopsis
The HttpSession
interface allows web applications to track
individual users across multiple HTTP requests. A session object is associated
with each user, either by setting a client cookie or rewriting request
URLs using the encodeURL()
method of
HttpServletResponse
. Servlet 2.2 confined the scope of
a session object to a particular web application, and replaced the
getValue()
and putValue()
methods with
the getAttribute()
and setAttribute()
methods.
When a session is first created, the isNew()
method will return true for the first servlet to process the request. If
the session information is lost (e.g., if the client does not support cookies)
the container will create a new Session
object for each
subsequent request.
public interface HttpSession { // Property Accessor Methods (by property name) public abstract java.util.Enumeration getAttributeNames(); // 2.2 public abstract long getCreationTime(); public abstract String getId(); public abstract long getLastAccessedTime(); public abstract int getMaxInactiveInterval(); // 2.1 public abstract void setMaxInactiveInterval(int interval); // 2.1 public abstract boolean isNew(); public abstract ServletContext getServletContext(); // 2.3 // Public Instance Methods public abstract Object getAttribute( String name); // 2.2 public abstract void invalidate(); public abstract void removeAttribute( String name); // 2.2 public abstract void setAttribute(String name, // 2.2 Object value); // Deprecated Public Methods public ...
Get Java Enterprise in a Nutshell, 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.