File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Iterate through multiple arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Iterate through multiple arrays" Watch "Iterate through multiple arrays" New topic
Author

Iterate through multiple arrays

Hasif Subair
Greenhorn

Joined: Aug 12, 2009
Posts: 24
I have 3 Arrays, say a[],b[] and c[]. I need to loop through these arrays and show the values on a jsp.



This can be done using scriptlets. but i am avoiding it completely. I need some tag to iterate all three array at once. Is it possible with <logic:iterate> tag or is there any other way to do this
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

It'd be substantially cleaner, and easier to test, to build a proper data transfer object on the server side. Iterate through *that* on the JSP side.
Hasif Subair
Greenhorn

Joined: Aug 12, 2009
Posts: 24
Actually David, i am getting these arrays from a html table. This table have more than one fields with the same property name. So when the form is submit it creates an array of values. These tables are dynamically added to the form, so their number is uncertain.

here are the codes from jsp files.



when the hyperlink is clicked the rows below are added to the form within the <div id="spec"> using ajax.


when you submit, it creates an array values for the above fields and are saved in action form. Now what i want, is to display the values of these field to the user in another jsp.

is there any better way of doing this?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'm not sure how that makes my suggestion not work.
Hasif Subair
Greenhorn

Joined: Aug 12, 2009
Posts: 24
Because My data transfer objects has some variables other than these arrays. These variable does not required to be iterated.

i resolved the issue by the following method.
I knew it, but didn't test it before posting it here.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Iterate through multiple arrays