File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "iterator problem" Watch "iterator problem" New topic

iterator problem

Jordan Josh
Ranch Hand

Joined: Aug 23, 2008
Posts: 38
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


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

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:
subject: iterator problem
It's not a secret anymore!