Re: Ending session
That's lot of idea. Thank you ever one. I will try them today, and I will post the results. Caine Lai wrote: Probably the easiest way to do this would be to have a very short session timeout period (5minutes?) set on the server. You could then have a JavaScript function that polls the server every 5 minutes. Each ajax request made by the JavaScript will reset the session timer on the server. On 6/5/07, Mansour [EMAIL PROTECTED] wrote: I am saving objects in the session. After the browser closes I would like to clean the remaining junk. How do I achieve this ? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Ending session
I am saving objects in the session. After the browser closes I would like to clean the remaining junk. How do I achieve this ? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Ending session
The server has no way of knowing if the client closes their browser. You'll just have to wait for the session to expire. -Original Message- From: Mansour [mailto:[EMAIL PROTECTED] Sent: 05 June 2007 12:34 To: Struts Users Mailing List Subject: Ending session I am saving objects in the session. After the browser closes I would like to clean the remaining junk. How do I achieve this ? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Ending session
If all the attributes are stored in the session then it will destroy itself .. but if you want to clean other stuff not stored in the session they try To write an HttpSessionListener http://www.java2s.com/Code/Java/Servlets/Servletsessionlistener.htm http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpSes sionListener.html Regards Guru -Original Message- From: Al Sutton [mailto:[EMAIL PROTECTED] Sent: 05 June 2007 12:41 To: 'Struts Users Mailing List' Subject: RE: Ending session The server has no way of knowing if the client closes their browser. You'll just have to wait for the session to expire. -Original Message- From: Mansour [mailto:[EMAIL PROTECTED] Sent: 05 June 2007 12:34 To: Struts Users Mailing List Subject: Ending session I am saving objects in the session. After the browser closes I would like to clean the remaining junk. How do I achieve this ? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Ending session
On 05/06/07, Mansour [EMAIL PROTECTED] wrote: I am saving objects in the session. After the browser closes I would like to clean the remaining junk. How do I achieve this ? Implement an HttpSessionListener. The destroy() method will be invoked by the servlet container when the session ends. You should be aware that unless you have some means of detecting when the browser closes or the user navigates away from your site and you destroy the session yourself, the destroy() method will not called until the session times out. Regards Roger - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Ending session
Mansour wrote: I am saving objects in the session. After the browser closes I would like to clean the remaining junk. How do I achieve this ? 1. provide a logout action. In this action, get the ServletRequest and invalidate the session immediately; but 2. if the user simply closes the browser, you have no option but to wait for the session to expire. Maybe all you really want is a shorter session timeout.; but 3. If you want a registry of all current sessions on the server so you can invalidate them manually, implement a HttpSessionListener and add this listener to web.xml. It will be notified whenever a session is created or destroyed so you to track the HttpSession objects yourself. Don't do this unless you really need it. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Ending session
2. if the user simply closes the browser, you have no option but to wait for the session to expire. Maybe all you really want is a shorter session timeout.; but I'm sure that I've read that it's possible, using Javascript, to detect if a client closes the browser if that's true, then you could use an AJAX call to invalidate the session. Having said that, unless the you store huge amounts of data in the session, it probably won't be too much of a problem to wait for the session to timeout on its own. Regards - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Ending session
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Roger, Roger Varley wrote: I'm sure that I've read that it's possible, using Javascript, to detect if a client closes the browser if that's true, then you could use an AJAX call to invalidate the session. This is possible, but you can't bet on it actually working. The user might have javascript disabled, or the browser may not fire javascript events as it's closing itself entirely (instead of just closing one window, for instance). Basically, the only reliable way to destroy a session is to wait for it to time out (unless the user explicitly logs out, of course). - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGZWnT9CaO5/Lv0PARAr7sAKCwRHe0YRnmJ2VvE1m73OIxkthBPgCgrp/f 7quPP1ZU7RT0rN3M6fqe2jI= =AvW9 -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Ending session
Roger Varley wrote: I'm sure that I've read that it's possible, using Javascript, to detect if a client closes the browser if that's true, then you could use an AJAX call to invalidate the session. This is possible, but you can't bet on it actually working. The user might have javascript disabled, or the browser may not fire javascript events as it's closing itself entirely (instead of just closing one window, for instance). Basically, the only reliable way to destroy a session is to wait for it to time out (unless the user explicitly logs out, of course). I would not disagree with this. However, you have to suspect that the majority of clients don't have Javascript turned off, otherwise Ajax wouldn't be the current favourite technology. :-) Regards Roger - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Ending session
I think the way it is mostly done is by using push events from the server. Have a look at Mortbay Jetty servlet container if you are really interested, It's supposed to handle continuations/push events quite well. If you can no longer push server events out you could make the assumption the client has disconnected. Greg Wilkins had a video on it not too long ago that was interesting - you should be able to find it on google easily. He's been working on the whole connection scalability issue for quite some time ( I think he had some experimental java.nio stuff back in v5.0). Overall though, I agree you can't reliably trust the browser to notify you of the end of session. Oz On 06/06/2007, at 12:42 AM, Roger Varley wrote: Roger Varley wrote: I'm sure that I've read that it's possible, using Javascript, to detect if a client closes the browser if that's true, then you could use an AJAX call to invalidate the session. This is possible, but you can't bet on it actually working. The user might have javascript disabled, or the browser may not fire javascript events as it's closing itself entirely (instead of just closing one window, for instance). Basically, the only reliable way to destroy a session is to wait for it to time out (unless the user explicitly logs out, of course). I would not disagree with this. However, you have to suspect that the majority of clients don't have Javascript turned off, otherwise Ajax wouldn't be the current favourite technology. :-) Regards Roger - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Ending session
Probably the easiest way to do this would be to have a very short session timeout period (5minutes?) set on the server. You could then have a JavaScript function that polls the server every 5 minutes. Each ajax request made by the JavaScript will reset the session timer on the server. On 6/5/07, Mansour [EMAIL PROTECTED] wrote: I am saving objects in the session. After the browser closes I would like to clean the remaining junk. How do I achieve this ? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]