Best way to detect browser closing/navigation to other page and do logout
I am writing an application in GWT and I need to detect when a user navigates away from my application or when he closes the browser window (onUnload event) and do a logout (session invalidation and few other cleanup tasks). The logout action is performed by a servlet. I am currently doing this by hooking into the onUnload() event and opening a new window pointed to the logout servlet. Is there a better way to do this? Any other suggestions are welcome. Looks like GWT does have an event for exactly this. ClosingEvent . Looks like you need to implement a ClosingHandler Why not just make a very