JSP Tutorials - Herong's Tutorial Examples - Version 4.03, by Dr. Herong Yang
What Is a Session?
This section describes what is a session - a concept to represent a series of HTTP requests and responses exchanged between a specific Web browser and a specific Web server.
What Is a Session?: Session is a concept to represent a series of HTTP requests and responses exchanged between a specific Web browser and a specific Web server, as illustrated in the following diagram:
Server Browser ID created | <-- Request #1 --- | | --- Response #1 --> | ID kept as cookie | <-- Request #2 --- | ID send back to server | --- Response #2 --> | | <-- Request #3 --- | ID send back to server | --- Response #3 --> | | ...... |
The session concept is managed by the server. When the first request comes from a browser on a new host, the server makes the beginning of a new session, and assigns a new session ID. The session ID will be then sent to the browser as cookie. The browser will remember this ID, and send the ID back to the server in the subsequent requests. When the server receives a request with session ID in them, it knows this is a continuation of an existing session.
When the server receives a request from a browser on a new host (request without a session ID), the server not only creates a new session ID, it also creates a new session object associated with the session ID. See the next section for details.
If there is no subsequent request coming back for a long time for a particular session ID, that session will be timed out. After the session has been timed out, if the browser comes back again with the associated session ID, the server will give an invalid session error.
Last update: 2012.
Table of Contents