Session Tracking in Servlet/JSP

What is Session?

Answer : A specific time span that user interact with the website, is persistent through out that time span.

Servlet serves the request made by the client and generates the dynamic output. But servlet is not capable enough to remember the last client who made the request by own, because it uses the HTTP protocol, which is a stateless protocol.

To make a session a persist, various approaches could be adapted by servlet like…

  • URL Rewriting (Query String) : Session information is persist by modifying query string. (client side)
  • Hidden Fields : Session information is persist using Hidden Fields in form. (client side)
  • Cookies : Session information is persist using Cookies in via browser in client’s computer. (client side)
  • Http Session : Session inormation is persist using Http Seesion object on server .(server side)

– Ravi Oza