This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts2 Iterator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 Iterator" Watch "Struts2 Iterator" New topic

Struts2 Iterator

Rajkumar Kathiresan

Joined: Dec 30, 2008
Posts: 8
I have a two map "student","address" in my action class.

I want to get the values from address map using the key of student map. ie., i need to append "S" with the key of student & need to pass that new value as a key for address Map. I tried some thing but its not working...

any one help me on this...
Peter Searls

Joined: Dec 21, 2009
Posts: 9

I modified your example a little to make things a little clearer.

Here are the entries from the jsp:
The iterator returns the EntrySet for each entry in the map.
To display the Student values you can just use the getKey() and getValue() methods.
To look up the student key to get the address, append the getKey() from the entrySet with
a literal 'S'.

Here are the results:
Student Key: 1 - Student Value: AAAA
Address Value: STREET1
Student Key: 2 - Student Value: BBBB
Address Value: STREET2

I hope this helps.

Pete Searls

Peter Searls
Rajkumar Kathiresan

Joined: Dec 30, 2008
Posts: 8
lol It worked for me Thanks.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Struts2 Iterator
Similar Threads
Problem in struts 2.0 autocompleter tag.
working with hashmap using struts2
substitute for DynaActionForm in struts2
iterate problem in struts2
Exception in thread "main" java.lang.Stack