Pr.Pg Next Pg

Deleting a Session tutorials

  • For removing the session object data JSP provides many way to do this each are explained below:

  1. invalidate() method: You can call invalidate method to delete entire session

Example: session.invalidate();

  1. web.xml Configuration: You can configure a session using <session-config> element of web.xml file if you are using tomcat server.

  • You can set session-timeout for automatically destroying a session when session is left stable for particular amount of time as below:




  • The above XML code tells the server to invalidate the user session if the session is stable for 20 minutes the default value is 30 minutes.

  1. removeAttribute() : removeAttribute method removes the object bound with the specified name from this session. If the session does not have an object bound with the specified name, this method does nothing. This method takes parameter as string which denotes the attribute name.

Pr.Pg border                                              Next Pg