Session Management

912 views
853 views

Published on

Published in: Business, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
912
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Session Management

  1. 1. Session Management
  2. 2. <ul><li>Web Container Sessions </li></ul><ul><li>Web container yendor is required to support sessions. Sessions are mechanism for storing the client-specific data across multiple HTTP requests. This is called session scope </li></ul><ul><li>Use an HttpSession </li></ul><ul><li>We can use an HttpSession object to hold the conversational state across the multiple request . In other words for the entire session for the client. </li></ul>
  3. 6. <ul><li>How the container will know who the client is ? </li></ul><ul><li>HTTP uses the stateless connections . The client browser makes the connection to the server, sends the request and get the response and closes the request . In other words connection exists for only single request/response. </li></ul><ul><li>Because the connection does not persist , the container does recognize that the client making the second request is the same client from the previos request. Container concerns that each request is the new request. </li></ul><ul><li>The idea is simple on the client first request, the container generates the unique session ID and give it back to the client with each response The client sends back the session ID with each request. The container sees the Id , finds the matching session, and associates the session with the client. </li></ul><ul><li>How the client and container exchange session Information? </li></ul><ul><li>The container has to get the session ID from the client as the part of the response and the client has to send back the session ID as the part of the request. The simplest and most common way to exchange through cookies. The best part is container does all these things virtually. You do have to tell the container that you want to use session but the container takes care of generating the session ID, creating the cookie object stuffing session ID into cookies and settind the cookie as a part of response . And subsequently request the container to get the session the session ID from the cookie in the request </li></ul>
  4. 7. <ul><li>Sending the session cookie in response </li></ul><ul><li>HttpSession session=request.getSession() </li></ul><ul><li>To know wether the session is already existed there is method called isNew() </li></ul>
  5. 8. <ul><li>HttpSession Methods </li></ul>

×