• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Iterating List of Maps through c:foreach

 
Kousik Majumder
Ranch Hand
Posts: 239
  • 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


 
Vijitha Kumara
Bartender
Posts: 3913
9
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: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes,

That is a typing mistake.
 
Chinmaya Chowdary
Ranch Hand
Posts: 434
  • 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: 239
  • 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: 434
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic