I have an ArrayList into which I add Beans(bean properties hold selected columns from DB). I have set the ArrayList as session attribute because I need to carry data over pages. On first jsp i have a retrieve button on submit of which data is displayed in a table on second jsp. The problem is -if the retrieve button is submitted 2 or 3 times ---the data is being added to the ArrayList(quite natural taht it would..)But i want to disable that effect. How can i do that? [ November 18, 2005: Message edited by: Bear Bibeault ]
I do not believe that that's applicable to this problem.
The problem sounds like you are managing the like cycle of your data poorly. The session data should have a distinct time at which it comes into being, a period in which it is active, and a time at which it is removed from scope.
It sounds as if you are not creating or removing the list at the approriate points, and therefore the same list is getting re-used when a new list would have been more appropriate. [ November 18, 2005: Message edited by: Bear Bibeault ]
Absolutely. You want to call the clear the arrayList before adding anything to it. I recently had to tackle a production problem where the app was slowing down because of session issues. The culprit was a collection that was not being cleared out. So on subsequent entries the data in the collection was doubling, and hence the session size. I was spitting out the session size, and noticed the drastic increase in session size on subsequent entry to the application (The data is read and the collection is populated without first clearing it out). You issue is similar.
Bosun (SCJP, SCWCD).
So much trouble in the world -- Bob Marley
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop