@melchkishore
Thanks for answer but what u said wont be struts 2, if i am not wrong.
Anyways can you be a bit more clear with some snippets if possible.
Main Topics
Browse All TopicsHi all,
i am using Struts 2. I have a Map that looks something like this.
Map<String,Object> map=new LinkedHashMap<String,Objec
Suppose key-values are
q1-object1
q2-object2
q3-object3
How do we get the value of say "q1" in jsp.
For example if in Action class we would do like this ;
map.get("q1");
How we achieve the same in using struts 2 tags in JSP. Or is scriptlets the only way (Because if possible i wouldnt want to do it using scriptlets!!)?
Thanks in advance
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
You can try like this below
In my Action class :
HashMap hmap = new HashMap()
map.put(q1,object1);
map.put(q2,object2);
map.put(q3,object3);
request.setAttribute("foru
in jsp
<logic:iterate>
<jsp:useBean id="forumList" scope="request" class="java.util.HashMap"/
<logic:iterate id="forums" name="forumList">
<tr><td><bean:write name="forums" property="key"/>=<bean:wri
property="value"/></td></t
</logic:iterate>
@summerian
Yes you are correct we do get the object using your method. Now the problem is a little bit more complicated.
I am already iterating a Map and key is an object. We use this object's property's value is used as the key to the map i was talking about in your example "myMap": See the cod snippet
Hope you have a solution.... :-)
You cannot nest JSP tags into their attributes. The attribute-nested tag will not be executed (it will be treated as simple string value):
<example:tag1 attr="<example:tag2/>" />
But that's what you have languages like JSP EL, and OGNL.
Learn more about OGNL:
http://struts.apache.org/2
http://www.ognl.org/
Solution is below
Hi summerian
when i do like this <s:property value='%{#myMap}'/> all the elements (Key-Value(Object)) is displayed. Also passing value explicitly say <s:property value='%{#objAssessmentMap
You have gained the points but still if you could help that would be great :-)
Thanks all you answered.
Business Accounts
Answer for Membership
by: melchkishorePosted on 2008-05-12 at 04:49:54ID: 21546031
Get the details from the Hashmap and put the values in the user defined bean say LabelValueBean which has attributes key and value with their getter and setter parameters and put them in a collection attribute of LabelValueBean and have the getter and setter methods of collection in FormBean. Try to access those collection of LabelValueBean and iterate in struts jsp using logic iterate tag.