This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HashMap - Get value by passing key  RSS feed

 
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
Boost this thread!