• Post Reply Bookmark Topic Watch Topic
  • New Topic

List<List<String>> to be rendered in JSP

 
Ankit Chandrawat
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an object of type List<List<String>> on JSP. This object has 3-5 List<String> objects. I want to iterate List<List<String>> object using <c:forEach> and assign the List<String>>objects to variables using <c:set>. How can I achieve this?

Thanks in advance
Ankit

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's just a list of lists, so you'll need nested foreach tags just as you'd need nested for loops in Java.

Give the code a try.
 
Ankit Chandrawat
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,

Thanks for the response. But the object here is to first fetch those list into different variables. As those lists will have to be used further for different purpose.

 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Different variables? I don't get it. What would be the names of those variables? And how would you match them up with the elements of the lists, given that there would be a fixed number of variables and a non-fixed number of list elements?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That makes no sense at all. How would you separate them into two variables in Java? Answer: you can't.

If you want two lists, create two lists from the outset.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!