I am trying to clear the HttpSession if the consumer close the browser window. I dont know how to do it, Please help me anyone
Thanks & Regards Chakri
EDITED :
try reading the answer on this Page
"HTTP is not a continuous-conversation protocol where the client connects to the server and they trade information asynchronously until the client disconnects.
Instead, each HTTP client request acts like it logs in, does one thing, then logs out. This request/response cycle repeats until the client stops sending requests.
At NO time is the server allowed to send a response to the client unless it's in response to a specific actual request and only one response is permitted per request.
So you cannot have a server post a "you timed out" page to the client. The closest you can get is to respond with a "you were timed out" response page if/when the client makes a request.
The other common thing people want to do is to notify the server that the client has closed a browser, window, or tab. There is no protocol defined for the World Wide Web to deal with that. If the user closes a server window/tab, the server is not notified by the client. Since there is no ongoing session to be dropped (remember, the connection only lasts long enough for the server to accept a request and return a response), there's no way the server will know that the client went away."
SUMMARIZATION :
YOU CAN'T DO IT
Possible Workaround :
You simply need to rely upon the session timeout. The timeout could happen at any time and you cannot even know if the user is even looking at one of your pages when it occurs. It's likely they're off looking at videos of kittens at the time.