Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Iterating List of Maps through c:foreach  RSS feed

 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

I have a list of maps.
Now I want to iterate the list in jsp page where i will give the key hardcoded to the map so that it returns the value corresponding to key.

Can somebody tell me how can I do that?





The bolded portion written in code does not work in foreach I suppose.
Please suggest.


Thanks,
Kousik


 
Bartender
Posts: 4044
47
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



I guess this is a typo ?

 
Kousik Majumder
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes,

That is a typing mistake.
 
Ranch Hand
Posts: 437
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Kousik. Use for getting keys.

Use for getting values.
 
Kousik Majumder
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


this will give the keys and values respectively which I do not want. I want a value with a particular key which i will give from outside like I showed before/below.
How can I do that?



Thanks,
Kousik
 
Chinmaya Chowdary
Ranch Hand
Posts: 437
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this,
Here the KEY is name of the attribute and the value must be your HashMap key. For example, pageContext.setAttribute("KEY","java"); Here "java" must be your HashMap key.
 
This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!