This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Struts and the fly likes iterator problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "iterator problem" Watch "iterator problem" New topic
Author

iterator problem

Jordan Josh
Ranch Hand

Joined: Aug 23, 2008
Posts: 36
Hi to All ranchers,
Hope you are fine.
I am trying to iterat ArrayList in jsp page.But I am not getting values from the arraylist.It just only display table header.
Please can somebody help me.

Here is my Action where I am populating the arraylist.


// Jsp Page:
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 689


Hi,


Please tell me one thing whay you store your list in to request and get it on Jsp.


Struts 2 have already OGNL functionality which gives direct to request parameter.

So do one thing declare your list variable at action with getter and setter method you directly get on the Jsp.


Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

It's not working as written because OGNL doesn't search JEE scopes. You need to explicitly tell OGNL to look in the request scope.

That said, Nishan's point is well-taken--there's no reason to do it like this, twice over. If you *are* dead-set on putting an object in the request it's much, much cleaner to implement RequestAware as opposed to ServletRequestAware. RequestAware doesn't tie your action to the servlet spec, making it significantly easier to test in isolation.

But again, simply exposing your ArrayList as an action property is cleaner, and your original JSP would work.

On a final note, in general we shouldn't define our variables as ArrayList, but as List or Collection: the implementation of the list is a detail we're only rarely concerned about in cases like this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: iterator problem