aspose file tools*
The moose likes Servlets and the fly likes session management -session not destroying automatically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "session management -session not destroying automatically" Watch "session management -session not destroying automatically" New topic
Author

session management -session not destroying automatically

Ramasubramaniam Rathinasubbu
Ranch Hand

Joined: Jun 09, 2010
Posts: 44
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

Joined: Apr 25, 2010
Posts: 510

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..


Regards, Prasad
SCJP 5 (93%)
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

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.


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Ramasubramaniam Rathinasubbu
Ranch Hand

Joined: Jun 09, 2010
Posts: 44
How can i get whether the client session is expired or not
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Nov 04, 2009
Posts: 2066

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

Joined: Sep 29, 2008
Posts: 12617

I don't understand the question--they're not doing anything out-of-the-ordinary. What behavior are you describing?
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

We want to invalidate the session, when we close the browser.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Jan 10, 2002
Posts: 61043
    
  66

This is a recording: you cannot detect when the browser closes.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pravin Shirke
Ranch Hand

Joined: Apr 05, 2008
Posts: 150

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.


[Vipassana] - It is seeing the reality as it is, And not as you want it to be.!!!
SCJP1.5.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: session management -session not destroying automatically