How can the Session in Servlet be destroyed?
Answered
How can the Session in Servlet be destroyed?
Best answer
An existing session can be destroyed in the following ways:
- Programmatically : Using session.invalidate() method, which makes the container abandon the session on which the method is called.
- When the server itself is shutdown.
- Setting timeout in the deployment descriptor: This can be done by specifying timeout between the <session-timeout>tags.
- Setting timeout programmatically: This will set the timeout for a specific session.