Monday, March 23, 2020

Servlet Session Tracking

Servlet Session Tracking


Session


Session simply refers to a particular time interval of communication between two interacting systems. Communication can take place in client-server or peer to peer mode of communication. 

HTTP Protocol

One of the most common types of client-server sessions is an HTTP based session upon the web. An HTTP session is started by a Web browser or a client program when we visit a website generally. For example, when we buy some items from an eCommerce website, the overall process of login, selection, and payment can be described as a session, even though we navigate through many different web pages available on that website. 

HTTP Request/Response
HTTP Request/Response

Session Tracking


The process of tracking the session is known as session tracking. As a developer, it is our responsibility to avail the mechanism of session tracking to the users. We need to store some data in some kind of temporary or permanent storage to keep the record of session variables. Session Tracking is a technique to maintain state (data) of a user, also known as session management in java servlet. 

Http Protocol


Http protocol is a stateless protocol,(Each time a user requests to the server, server treats the request as the new request every time) it does not inherently provide us any mechanism for managing a session. Therefore, we can keep state information stored by using different session tracking mechanisms. 

Why Session Tracking?


  • Session Tracking is used to recognize (maintain the data of the users) the particular user.
  • It is almost impossible to create web applications for online shopping, e-mailing applications, E-Commerce web application to keep the record of the conversion without session tracking. 

Java Servlets Session Tracking Techniques 


We can use four techniques for Session tracking in Java Servlets, 

  • Cookies
  • HttpSession
  • Hidden Form Field
  • URL Rewriting
Session Tracking Techniques
Session Tracking Techniques