Session management in servlet
- how to create session in servlet
- how to create session in servlet and jsp
- how to set session timeout in java servlet
- session in servlet example
What is session in servlet
Http session example.
The HttpSession Interface in Servlet
What is a session?
In web terminology, a session is simply the limited interval of time in which two systems communicate with each other.
The two systems can share a client-server or a peer-to-peer relationship. However, in Http protocol, the state of the communication is not maintained.
Httpsession in servletHence, the web applications that work on http protocol use several different technologies that comprise Session Tracking, which means maintaining the state (data) of the user, in order to recognize him/her.
However, they have the following disadvantages:
- They can only keep textual information.
- They’re browser dependent.
Hence, if the client disables them, your web application can’t make use of them
How to create sessions with a unique session id for each user in java servlet
For this, servlets provide an interface called ‘HttpSession’ Interface.
The following diagram explains how Http Sessions work in servlets:
Methods in HttpSession Interface
Method | Description |
---|---|
public HttpSession getSession() | Gets the Http
|