Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HashMap - Get value by passing key

 
aamchi mumbai
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i have hasmap like this

HashMap hm = new HashMap();
hm.put("id", "101");
hm.put("name", "java");

request.setAttribute("data", hm);

now i want use struts tag to display value of ID key. is there any way i can pass KEY and i can get value for that key. i dont wat to iterate.

Thanks in advance
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Struts is smart enough to know when an object implements the Map interface, so all you have to do is give the key value as the property. For example, the following tag will display "java" in your example:

<bean:write name="data" scope="request" property="name" />
[ May 05, 2005: Message edited by: Merrill Higginson ]
 
aamchi mumbai
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank for Help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic