• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

How to detect browser disconnection?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using Tomcat to host a site developed using JSP and Java beans. Whenever a user logs into this site a session is created and is terminated when the user presses log out button.
There is a problem however, that the session remains active if the user closes the browser without logging off.
I am aware that HTTP is a stateless protocol, but I would like to find out if there is a way by which I can detect whether the client is still connected to the website or moved on so I can invalidate his session.
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've seen some sites that use JavaScript to detect if the browser has been closed or if the user has left the site. But you can't be dependent on this information -- not all browsers support javascript, and it can be turned off by the user.
You're going to have to change the sessionTimeout to an acceptable length (long enough for someone to surf around the site and not get kicked off 'cause they took too long but short enough to catch people that leave the site and don't intend to come back.
------------------
- Jessica Bradley
HP Bluestone
 
author
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please do not post the same question is multiple forums. Please address further discussions here.
http://www.javaranch.com/ubb/Forum7/HTML/006871.html
Sean
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic