26. Explain JSP Session implicit Object.

  1. The session implicit object is used to provide an association between the client and the server. This association, or session, persists over multiple connections and/or requests during a given time period. Sessions are used to maintain state and user identity across multiple page requests.
  2. A session can be maintained either by using cookies or by URL rewriting. To expose whether the client supports cookies, session defines an isCookieSupportDetermined() method and an isUsingCookies() method.

Servlet Class

HttpSession

The following table summarises the most useful methods available to the session object.

isNew()
A session is considered to be “new” if it has been created by the server, but the client has not yet acknowledged joining the session.

invalidate()
Discards the session, releasing any objects stored as attributes.

getAttribute(String)
Retrives the object associated with the named attribute.

getAttributeNames()
Retrives the names of all attributes currently associated with the session.

setAttribute(String, object)
Sets the object to the named attribute. attribute created if it doesn’t exist.

removeAttribute(String)
Removes the object bound with the specified name from this session.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: