• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Nested C:forEach varStatus ??

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have two string arrays

in servlet

String [] s1 = {"A","B","C"};
String [] s2= {"X","Y","Z"};

java.util.List slist = new java.util.ArrayList
slist.add(s1);
slist.add(s2);
request.setAttribute("slist",slist);

Now i forward the request to a jsp


in Jsp

I'm using C:forEach tag.... i want the output to be

1 A
2 B
3 C
4 X
5 Y
6 Z

how i can use the varStatus to get the total count !!!
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dude,

To get the desired output as u have mentioned u'll have to nest two <c:forEach> tags.

<c:forEach var="outer" items="${slist}" >
<c:forEach var="inner" items="${outer}" varStatus="num">
Count is ${num.count} Item is ${inner}
<BR>
</c:forEach>
</c:forEach>

hth.
Humble reqst to Guys to pls address the query i posted.
 
Mike Pandey
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey man ...Apologies for missing out on the o/p u desired .
In your case you wud need to have the old "scripting along with JSTL
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure you can, because I think that you'll need to keep track of the size of the lists you've already printed.
Why don't you use a different variable ?

 
Rajesh Vijaya
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the code ...Satau

since there is relationship between items of the inner Foreach and the var of the outer Foreach i thought there might be relationshiop between their varStatus also.....
 
Did you miss me? Did you miss this tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic