Session Tracking in a JSP Page
by, 07-07-2012 at 08:12 PM (1963 Views)
JSP communicates with the clients using stateless HTTP protocol. For each new request, following operations are performed:
A new connection is opened with web server.
Server does not record client information.
In this topic, we will focus on the different ways of handling and maintaining session information. Following are the 3 main ways for session maintaining.
Cookies: A cookies also known as session ID is assigned to a web client by the webserver for first request. Next time this session ID is used to recognize the client and maintain a session. There are cases in which web browser does not support cookies so it is not a recommended way of maintaining session.
Hidden Fields: Session can be maintained between client and webserver using hidden form fields. These hidden fields are automatically included with the form data and a unique value is communicated between client and server for session handling. This is a recommended approach for maintaining session but in case of hyper link click, it will not send the hidden fields so its hard to maintain session in such cases.
URL Rewriting: The session information can be appended at the end of of URL. It is a recommended way of maintaining sessions and it will also work for those browsers which do no support cookies.