How can the Session in Servlet be destroyed?
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.