I am not sure where i am going wrong. But my code below is accessiong the "menArraylist" 2wice and every time only the last element is being diplayed. when I try to display the values of menArrayList in the Action class it is showing me the right values. Can anybody tell me where i am going wrong.
There are at least a couple of issues with this code:
1) Line 4 adds the same object to the list, over and over. Line 2 changes a property of the object you're adding, so you end up seeing the same value multiple times. This is almost certainly not what you want, and explains why you're seeing the same values.
2) Line 5: There's no reason to set the same list into the session over and over. Just do it once, outside of the loop.
(See how helpful posting the actual code was?)
Joined: Jun 09, 2009
Sir i understood he 2nd point what you mentioned but regarding the first one menlist is
so everytime i add a new value to menlist.setCategory_name I guess it should appened the value. This is what i thought it does.