Question - How do you delete the Session Data?
Answer -
Deleting the Session Data involves the following steps.
- Remove a particular attribute: public void removeAttribute(String name) method is called to delete the value associated with the particular key.
- Delete the whole session: public void invalidate() method is called to discard an entire session.
- Setting the Session timeout: public void setMaxInactiveInterval(int interval) method is called to set the timeout for a session individually.
- Log the user out: The logout is called to log the client out of the Web server and invalidate all sessions belonging to all the users.
- web.xml Configuration: In Tomcat, using the above-mentioned methods, one can configure session time out in web.xml file as follows.