• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Nested C:forEach varStatus ??

 
Rajesh Vijaya
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • 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 !!!
 
Mike Pandey
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.....
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic