Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Iterate HashMap in jsp - Struts2  RSS feed

Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!