File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes HashMap - Get value by passing key Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "HashMap - Get value by passing key" Watch "HashMap - Get value by passing key" New topic
Author

HashMap - Get value by passing key

aamchi mumbai
Greenhorn

Joined: Mar 04, 2005
Posts: 19
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

Joined: Feb 15, 2005
Posts: 4864
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 ]

Merrill
Consultant, Sima Solutions
aamchi mumbai
Greenhorn

Joined: Mar 04, 2005
Posts: 19
Thank for Help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HashMap - Get value by passing key