Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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

 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Sheriff
Posts: 67619
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Sheriff
Posts: 26958
84
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67619
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic