Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

valueUnbound()

 
Ajai
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All ,
I am having an object which implements HttpSessionBindingListener , and in my servlet I am setting a session attribute for this object .
Calling invalidate triggers a call to valueUnbound method.
My doubt is
Will closing the browser window by clicking the cross button at the top right corner trigger a call to valueUnBound method()???
I think it does not.
Any suggestions /explanations ???
Thanks ,
Buggi .
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will closing the browser window by clicking the cross button at the top right corner trigger a call to valueUnBound method()???
I think it does not.

No! Server does not know what happens to the browser, unless you send a request.
[ August 26, 2002: Message edited by: Roseanne Zhang ]
 
Ajai
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many 2 Thanx ,
I checked that it calls valueUnbound after session times out.
Thanks again.
Buggi.
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct, Buggi Sandhu.
I believe you know session timeout is not the same as closing browser, even they might be/not be related.
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder if there is a way to trigger session.invalidate() when the browser is closed.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bruce Jin:
I wonder if there is a way to trigger session.invalidate() when the browser is closed.
The only way that I have seen is a very ugly frame- and JavaScript-based hack that would submit a special request to the server whenever the user closed the browser or went off somewhere else. The servlet this request went off to would then invalidate the user session.
Obviously, given that there is no guarantee that the client supports frames and JavaScript in the first place, even this is not a foolproof method.
- Peter
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bruce Jin:
I wonder if there is a way to trigger session.invalidate() when the browser is closed.

This is not only a thing hard to do as Peter pointed out, but also a WRONG thing to do. Since user might open several browser windows belong to the same session. If user close one window, you invalidate the session, user will be annoyed since they need to re-login the site they might just logged in a minute ago. The RIGHT way is letting user logout explicitly!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic