Meaningless Drivel is fun!*
The moose likes JSP and the fly likes Iterating List of Maps through c:foreach Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Iterating List of Maps through c:foreach" Watch "Iterating List of Maps through c:foreach" New topic
Author

Iterating List of Maps through c:foreach

Kousik Majumder
Ranch Hand

Joined: Sep 30, 2007
Posts: 234
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



Thanks in Advance,
Kousik
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3855



I guess this is a typo ?



SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Kousik Majumder
Ranch Hand

Joined: Sep 30, 2007
Posts: 234
yes,

That is a typing mistake.
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
Hi, Kousik. Use for getting keys.

Use for getting values.
Kousik Majumder
Ranch Hand

Joined: Sep 30, 2007
Posts: 234


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

Joined: Apr 21, 2008
Posts: 432
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Iterating List of Maps through c:foreach