• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

session scope causing a problem

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 687
Mac
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may like to look at--
Double Submit problem
 
Sheriff
Posts: 67749
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic