HTTP
is a state-less protocol, i.e, once your request processed, then
there is no relation between you(browser) and the server. The HTTP
protocol is stateless, so the server and the browser should have a
way of storing the identity of the user through multiple requests.
Session
management is necessary in almost all applications, For example, a
shopping cart application should know who is sending the request to
add an item and in which cart the item has to be added or who is
sending checkout request so that it can charge the amount to correct
client.
There
are three typical solutions to this problem.
1. Cookies
2. URL
rewriting
3. Hidden
form fields
But
Servlets provide a robust solution using the HttpSession API.
Session
management process is like below.
Step
1 : Client send first request
Step
2 : Container generates unique
session id and gives it back to client with the response.
Step
3 : The client sends back the
session id for each subsequent requests.
Step
4: Container checks the session
id and use the data associated with the session.
No comments:
Post a Comment