Servlets - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Servlets Session

Servlets Session

shape Description

Servlets Session, First developer has to understand the requirement of tracking the session data HTTP is a stateless, protocol which means that whenever a client sends the request to the server, it processes the instructions and gives response back to the client, but the data may be valid or invalid, once providing a response to the client then the server does not responsible for the client data. Before learning more first user has to know that what is HTTP protocol and why HTTP is stateless Protocol.

shape Conceptual figure

The Stateless behavior means, while processing the current request in any web resource program one cannot use previous request data. That means while processing request2, request1 data cannot be used. Similarly,  while processing request3 and request1, request2 data cannot be used.

shape Techniques

If a web application is capable of remembering a client data during a session across the multiple requests then that web application is called as a stateful Web application. Even though HTTP is a stateless protocol, web applications should be made as stateful web applications. For this, working with the following session tracking or session management techniques is necessary. Servlets Session tracking is all about making web application as stateful web application by remembering client data across the multiple requests during a session. Following are the RealTime Implementation of Servlets Session tracking/session management.

Difference Between Cookies And Sessions

Sessions are server-side files that contain user information, while Cookies are client-side files that contain user information. Sessions have a unique identifier that maps them to specific users. This identifier can be passed in the URL or saved into a session cookie. Most of the sites use the second approach, saving the identifier in a Cookie instead of passing it in a URL (which poses a security risk).

Summary

shape Key Points

  • Servlets Session - Session can be defined as specific interval of time.
  • If HTTP is stateless then each request will be treated as new request from the web server.
  • To identify specific user session tracking will be used.