SlideShare a Scribd company logo
Session Management
Web Container Sessions 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 Use an HttpSession 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.
 
 
 
How the container will know who the client is ? 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. 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. 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. How the client and container exchange session Information? 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
Sending the session cookie in response HttpSession session=request.getSession() To know wether the session is already existed there is method  called isNew()
HttpSession Methods

More Related Content

PPTX
Building a new feature with microservice while moving away from monolithic ap...
PPTX
Introduction to Blockchain and Ethereum
KEY
OAuth 2.0
PDF
Ethereum Solidity Fundamentals
PDF
Identity patterns and anit-patterns in real world web services
PPTX
Blockchain Tokenization
PPT
Servlet11
PPT
Internetbasics
Building a new feature with microservice while moving away from monolithic ap...
Introduction to Blockchain and Ethereum
OAuth 2.0
Ethereum Solidity Fundamentals
Identity patterns and anit-patterns in real world web services
Blockchain Tokenization
Servlet11
Internetbasics

Similar to Session Management (20)

PDF
Servlet sessions
PPTX
Session And Cookies In Servlets - Java
PPTX
Enterprise java unit-2_chapter-3
PPTX
Using cookies and sessions
PPTX
01 session tracking
PPTX
IMPORTANT SESSION TRACKING TECHNIQUES.pptx
PDF
Jsp session tracking
PPTX
Class 38
PPTX
Session tracking In Java
PPTX
Maintest 100713212237-phpapp02-100714080303-phpapp02
PPTX
Maintest 100713212237-phpapp02-100714080303-phpapp02
PPTX
Session tracking in servlets
PPTX
Advanced java+JDBC+Servlet
PPT
Basics Of Servlet
PPTX
Http session (Java)
PPT
PPTX
J2ee servlet
PPT
Session and state management
Servlet sessions
Session And Cookies In Servlets - Java
Enterprise java unit-2_chapter-3
Using cookies and sessions
01 session tracking
IMPORTANT SESSION TRACKING TECHNIQUES.pptx
Jsp session tracking
Class 38
Session tracking In Java
Maintest 100713212237-phpapp02-100714080303-phpapp02
Maintest 100713212237-phpapp02-100714080303-phpapp02
Session tracking in servlets
Advanced java+JDBC+Servlet
Basics Of Servlet
Http session (Java)
J2ee servlet
Session and state management
Ad

More from patinijava (16)

PPT
Web Services Part 2
PPT
Web Services Part 1
PPT
Struts N E W
PPT
S E R V L E T S
PPS
Struts Java I I Lecture 8
PPT
Servlet Api
PPT
Sping Slide 6
PPT
Entity Manager
PPT
PPT
PPT
PPT
Patni Hibernate
PPT
Spring Transaction
PPT
Webbasics
PPT
PPT
Portlet
Web Services Part 2
Web Services Part 1
Struts N E W
S E R V L E T S
Struts Java I I Lecture 8
Servlet Api
Sping Slide 6
Entity Manager
Patni Hibernate
Spring Transaction
Webbasics
Portlet
Ad

Recently uploaded (20)

PDF
Laughter Yoga Basic Learning Workshop Manual
PPTX
Lecture (1)-Introduction.pptx business communication
PDF
How to Get Funding for Your Trucking Business
PDF
COST SHEET- Tender and Quotation unit 2.pdf
PDF
Solara Labs: Empowering Health through Innovative Nutraceutical Solutions
PPTX
Board-Reporting-Package-by-Umbrex-5-23-23.pptx
PDF
Tata consultancy services case study shri Sharda college, basrur
PDF
Chapter 5_Foreign Exchange Market in .pdf
PDF
Roadmap Map-digital Banking feature MB,IB,AB
PPTX
2025 Product Deck V1.0.pptxCATALOGTCLCIA
PDF
IFRS Notes in your pocket for study all the time
PPTX
Dragon_Fruit_Cultivation_in Nepal ppt.pptx
PDF
NewBase 12 August 2025 Energy News issue - 1812 by Khaled Al Awadi_compresse...
PDF
How to Get Business Funding for Small Business Fast
DOCX
unit 1 COST ACCOUNTING AND COST SHEET
PDF
Outsourced Audit & Assurance in USA Why Globus Finanza is Your Trusted Choice
PDF
SIMNET Inc – 2023’s Most Trusted IT Services & Solution Provider
PDF
Daniels 2024 Inclusive, Sustainable Development
DOCX
Business Management - unit 1 and 2
PPTX
Belch_12e_PPT_Ch18_Accessible_university.pptx
Laughter Yoga Basic Learning Workshop Manual
Lecture (1)-Introduction.pptx business communication
How to Get Funding for Your Trucking Business
COST SHEET- Tender and Quotation unit 2.pdf
Solara Labs: Empowering Health through Innovative Nutraceutical Solutions
Board-Reporting-Package-by-Umbrex-5-23-23.pptx
Tata consultancy services case study shri Sharda college, basrur
Chapter 5_Foreign Exchange Market in .pdf
Roadmap Map-digital Banking feature MB,IB,AB
2025 Product Deck V1.0.pptxCATALOGTCLCIA
IFRS Notes in your pocket for study all the time
Dragon_Fruit_Cultivation_in Nepal ppt.pptx
NewBase 12 August 2025 Energy News issue - 1812 by Khaled Al Awadi_compresse...
How to Get Business Funding for Small Business Fast
unit 1 COST ACCOUNTING AND COST SHEET
Outsourced Audit & Assurance in USA Why Globus Finanza is Your Trusted Choice
SIMNET Inc – 2023’s Most Trusted IT Services & Solution Provider
Daniels 2024 Inclusive, Sustainable Development
Business Management - unit 1 and 2
Belch_12e_PPT_Ch18_Accessible_university.pptx

Session Management

  • 2. Web Container Sessions 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 Use an HttpSession 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.
  • 3.  
  • 4.  
  • 5.  
  • 6. How the container will know who the client is ? 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. 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. 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. How the client and container exchange session Information? 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
  • 7. Sending the session cookie in response HttpSession session=request.getSession() To know wether the session is already existed there is method called isNew()