File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Iterate HashMap in jsp - Struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Iterate HashMap in jsp - Struts2" Watch "Iterate HashMap in jsp - Struts2" New topic

Iterate HashMap in jsp - Struts2

Arun Christopher

Joined: Nov 18, 2008
Posts: 19
In my application I have to display menu items from database

Each menu Item(MenuVO) will have a menu-id(menuId), parent-menu-id(parentMenuId), menu-order(menuOrder).

I have a hashmap which contains a menu item as the key and sub menus as ArrayList of menus.

But the submenu items can also be a parent for a list of sub-sub-menu items.

How can I iterate this recursive HashMap in JSP/java(I can create a custom tag).

The menu will be displayed as

I know the menu goes only 4 or 5 levels deep but I dont want to hardcode 4 or 5 nested iterators in jsp.

Included screenshots for better understanding


Need to be arranged in below fashion and iterated in jsp(struts2)

This is also a similar thread


I agree. Here's the link:
subject: Iterate HashMap in jsp - Struts2
It's not a secret anymore!