• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.
Thanks for the help.
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not really - there's no real difference between running 2 browser windows attached to 2 different websites and one window where the user bounces back and forth between the 2 websites, as long as the client-side session context is preserved. By which I mean that either cookies are in use or the user is clicking on rewritten URL rather than manually entering one (since a manually-entered URL is unlikely to contain the session ID).
You'll do better to just shorten the session timeout if that's a problem. That also allows for the case where a user "logs out" because their computer crashed.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic