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

session management -session not destroying automatically

 
Ramasubramaniam Rathinasubbu
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all



in my application i am maintaining the session using

HttpSessionListener

public void sessionCreated(HttpSessionEvent se)
public void sessionDestroyed(HttpSessionEvent se)

If one user close the browse abrubtly, the browser's session should destroyed,
but it is not destroying automatically

OS : Linux
application : Jboss


How can i maintain the session
 
Prasad Krishnegowda
Ranch Hand
Posts: 670
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a user closes the browser abruptly, session will not be destroyed, it will be still active, session is destroyed after the session time out period is expired..
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can you do it with HTTP protocol? With HTTP, only client can initiate the conversation. If you close the browser, then how do you notify it to server? You can do it with JS/AJAX. Try it.
 
Ramasubramaniam Rathinasubbu
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i get whether the client session is expired or not
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramasubramaniam Rathinasubbu wrote:How can i get whether the client session is expired or not

There is no session on the client side.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abimaran Kugathasan wrote:How can you do it with HTTP protocol? With HTTP, only client can initiate the conversation. If you close the browser, then how do you notify it to server? You can do it with JS/AJAX. Try it.

Not reliably, nor will it handle browser or machine crashes, nor if the user has JavaScript turned off.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:
Not reliably, nor will it handle browser or machine crashes, nor if the user has JavaScript turned off.

Agreed! But, how do know it? How did GMail solve this?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand the question--they're not doing anything out-of-the-ordinary. What behavior are you describing?
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We want to invalidate the session, when we close the browser.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Onbeforeunload or something like that is your only hope, and it doesn't cover all circumstances, and covers *none* of them if JavaScript is turned off.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64972
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a recording: you cannot detect when the browser closes.
 
Pravin Shirke
Ranch Hand
Posts: 152
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi abimaran,
I think david is right, you need to call Onbeforeunload to invalidate the session. but in Onbeforeunload make a Ajax call and call a servlet which will invalidate the existing session this is the only way you can invalidate the session on browser close.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic