Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes JSP and the fly likes recording time when the user closed browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "recording time when the user closed browser" Watch "recording time when the user closed browser" New topic

recording time when the user closed browser

as chhipa

Joined: Sep 04, 2006
Posts: 26
Hi everybody,
I want to know if there is any mechanism is JSP through which we can detect the time when user closed the browser window so that we can record the logout time in database. It will be very nice if you can provide the sample code also.
Thank you.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

There is nothing in JSP for this.

There is no reliable way to know when a user closes a browser from the server.
  • Http is a stateless protocol
  • Computers crash.
  • Network connections dissapear.
  • Browsers can be configured to do or not do lots of things.
  • Users could type new URLs in the browser's address bar.

  • [ September 27, 2006: Message edited by: Ben Souther ]

    Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
    Consider Paul's rocket mass heater.
    subject: recording time when the user closed browser
    Similar Threads
    Do stuffs when browser closes
    Problem in closing the browser in web forms
    Session Management--Telling objects to go away!
    How to invalidate the session on browser close.
    Getting NullPointerException while counting number of visitors using session