Can any of you provide a code snippet to end the user's session on closing the browser using the servlets. actually i don't want any logout buttons in the application,so I need to end the user's session when they closes their browser.
bhaskar selvaraj wrote:Hi,
actually i don't want any logout buttons in the application,so I need to end the user's session when they closes their browser.
Why you don't need any logout button?
There is no reliable way to find out the close of browser, you need to rely upon the session timeout...
SCJP 5 (93%)
Joined: Nov 05, 2012
I saw one application basically built using servlets and JSP without logout functionality, but when you close the browser the user's session ends and if you hit again that URL by re-opening the browser it displays a login screen.
Regarding the clarification you gave,
Do you mean the <session-timeout> tag in the web.xml. If not could you explain me in detail.
Yes i meant session-time-out. You can set it to a very minimum value, say 5 mins, but the disadvantage of this is, even if the user is idle for 5 mins, without closing the browser, the session gets expired.