Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to end the user's session on closing the browser

 
bhaskar selvaraj
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.



Thanks,
Bhaskar
 
Prasad Krishnegowda
Ranch Hand
Posts: 670
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
bhaskar selvaraj
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Prasad,

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.

 
Prasad Krishnegowda
Ranch Hand
Posts: 670
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic