• Post Reply Bookmark Topic Watch Topic
  • New Topic

session scope causing a problem  RSS feed

 
Preetha Shenoy
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Jignesh Patel
Ranch Hand
Posts: 626
Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may like to look at--
Double Submit problem
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jignesh Patel:
You may like to look at--
Double Submit problem


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 ]
 
Preetha Shenoy
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You r right bear. I looked back at my code and i set the arrayList.clear() to clear the data out of the arrayList. The records dont get displayed now. It was nothing about session.removeAttribute etc.

Thanks everyone.
 
Bosun Bello
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!