I'm developing a Struts based application that will store JavaBeans in the Session. I read that objects stored in the Request scope are cleaned up automatically by the system. However, I haven't read anything about how to clean them up from the session scope.
I'm expecting to have a "Logout" type operation where this will occur. Other than setting the object to null is there any thing else I need to do? Also, is there a way to handle these objects if a user just closes their web browser rather than logging out?
Thanks in advance,
Chris
-
Struts - How do I clean up Session objects? (7 messages)
- Posted by: Chris Smith
- Posted on: June 18 2004 09:50 EDT
Threaded Messages (7)
- Struts - How do I clean up Session objects? by VIJAY KHANNA on June 18 2004 10:40 EDT
- Struts - How do I clean up Session objects? by Rajasekar Kayamboo on June 18 2004 13:43 EDT
- Suggested Approach by Trevor Brosnan on June 19 2004 12:50 EDT
- Suggested Approach by Rolf Zelder on June 19 2004 19:24 EDT
- I too, am interested in this approach. by Chris Smith on June 21 2004 08:52 EDT
-
Approach to Session Management by Trevor Brosnan on June 21 2004 04:01 EDT
- Approach to Session Management by Thiru Kumar on August 17 2005 08:26 EDT
-
Approach to Session Management by Trevor Brosnan on June 21 2004 04:01 EDT
-
Struts - How do I clean up Session objects?[ Go to top ]
- Posted by: VIJAY KHANNA
- Posted on: June 18 2004 10:40 EDT
- in response to Chris Smith
I'm developing a Struts based application that will store JavaBeans in the Session. I read that objects stored in the Request scope are cleaned up automatically by the system. However, I haven't read anything about how to clean them up from the session scope.I'm expecting to have a "Logout" type operation where this will occur. Other than setting the object to null is there any thing else I need to do? Also, is there a way to handle these objects if a user just closes their web browser rather than logging out?Thanks in advance,Chris
-
Struts - How do I clean up Session objects?[ Go to top ]
- Posted by: Rajasekar Kayamboo
- Posted on: June 18 2004 13:43 EDT
- in response to Chris Smith
Clean up is an every programmer's job. If you throw objects in session. You can do a once for all clean up when you invalidate the session. If you need to slectively remove the objects, you need to do session.removeAttibute("xxx");
Hope this gives a lead in the direction where you want to go!
Cheers
Sekar -
Suggested Approach[ Go to top ]
- Posted by: Trevor Brosnan
- Posted on: June 19 2004 12:50 EDT
- in response to Chris Smith
If you are going to make extensive use of the session, I would strongly recommend that you think about implementing some form of application infrastructure to handle/manage session data. This will ensure that Session data is tightly controlled by the application, which can alleviate memory issues, as well as possible side-effects.
It could be organized by use-case. Take for example a multi-step wizard screen. Your design should specify what data will be placed in the session at each step, and what the valid values can be. A higher level entity (say a SessionManager class called on every request by the Struts Request Processor (which you can overload)) can examine the session and determine what use-case is being executed. If the user has changed use-case, then all the session data for any other use-cases should be removed.
That is a high-level description of an approach I have taken. If you want to know more, post a reply, and I can send some more detail.
As an aside, if the user closes their browser, you can run a tiny bit of JavaScript to detect this and send a logout message back to the server (this is no good if they just change the URL in the browser though). See my post at http://www.theserverside.com/discussions/thread.tss?thread_id=25891
Regards,
Trevor -
Suggested Approach[ Go to top ]
- Posted by: Rolf Zelder
- Posted on: June 19 2004 19:24 EDT
- in response to Trevor Brosnan
I'm quite interested in your high-level approach. Would you mind to send more details about it
Thanks
Rolf -
I too, am interested in this approach.[ Go to top ]
- Posted by: Chris Smith
- Posted on: June 21 2004 08:52 EDT
- in response to Trevor Brosnan
Would you send more information about this, please. Thanks for your feedback.
Chris -
Approach to Session Management[ Go to top ]
- Posted by: Trevor Brosnan
- Posted on: June 21 2004 16:01 EDT
- in response to Chris Smith
All,
I have posted a bit more detail and comment on my weblog, at http://trevorb.blog-city.com/.
I am quite busy at the moment, but if people are interested, I can do up some code and make it part of an article or similar. If you want to see this, please post a comment to the weblog.
Regards,
Trevor -
Approach to Session Management[ Go to top ]
- Posted by: Thiru Kumar
- Posted on: August 17 2005 20:26 EDT
- in response to Trevor Brosnan
I know its been long time, but i pumped into the same problem now- cleaning up the session objects.
Trevor, the blog doesn't exist anymore. Just curious, do you have any other pointer? Thanks.