Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to do more than one loops togeter?  RSS feed

 
Joshua Cloch
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In jsp,it is very easy to loop an array using <c:forEach>....</c:forEach>.

However,I feel confused to operate two arrays together.
Say, I have two string arrays(may be more complicated in reality),they have the same lengths.I want to assign the value from one array to the other.

Two arrays:A,B
Assigning values: A[0]=B[0];A[1]=B[1]......A[i]=B[i]

Can I use something similar to the "i" used in above in jsp?Or,there is someother tags to operate more than one arrays?

Thanks very much!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66187
148
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a copy of the JSTL specification open on your desktop (virtual or otherwise)?

If so, look up the various configurations for the <c:forEach> tag for your answer.
 
Joshua Cloch
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, i have checked the jstl api,
<c:forEach> only has six attributes: items, begin, end, step,var, varStatus.

i dont see any combination of them can solve that problem.

ant ideas?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66187
148
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly, the type of thing you are talking about, copying data around, should be done in the controller before the JSP page is even displayed. JSPs are for view, not processing.

But my point with regards to iterating through multiple arrays in step with each other, is that it can easily be accomplished via the begin, end and varStatus attributes to <c:forEach>.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!