Continues executing code after closing window.

asked 2011-11-22 09:54:50 +0800

Neus gravatar image Neus
1415 14

When a user enter in the application I'm making some verifications such as if the same user is connected from another IP. If one of this verification fails I'm showing an error message and I close the window using javascript (window.close()). After closing the window I realize that the application continues running the code as if the window had not been closed.
I try closing window using the cross of the navigation and the same happened.

Is that a normal behaviour? How can I avoid that?

Thank you

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2011-11-23 04:28:26 +0800

SimonPai gravatar image SimonPai
1696 1

Correct, Desktops die with Sessions if user closes browser window directly. ZK's SessionCleanup will be invoked upon session destruction, which I believe is implemented via HttpSessionListener.sessionDestroyed(). You can also count on DesktopCleanup, just remember that if the user close browser window directly, it may stay as long as the session lives (but they will eventually die, as soon as session timeouts), and in other cases (like changing a page, etc) desktop are closed as soon as possible.

link publish delete flag offensive edit

answered 2011-11-22 12:05:32 +0800

Neus gravatar image Neus
1415 14

So, no matter if the window is closed, resources are still there occupying memory?
SessionCleanup or HttpSessionListener.sessionDestroyed() are called everytime Session is destroyed even for timeout? The correct thing will be freeing resources in which of these two?

link publish delete flag offensive edit

answered 2011-11-22 10:31:54 +0800

SimonPai gravatar image SimonPai
1696 1

In the HTTP standard, it is not required to send a request upon closing the browser window (either by user or javascript), so unfortunately on the server side there is no way to tell whether the user has closed the window.

The only way to know exactly the user has left is Session timeout (which is partly the reason it's designed this way). You can try to listen to Session timeout to do some clean up, but it is quite hard to immediately know if the user leaves.


link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2011-11-22 09:54:50 +0800

Seen: 420 times

Last updated: Nov 23 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More