I'm looking to create a horizontal menu in a jsp page - the menu items vary by user but stay consistent over every page in the site for that user apart from the appearance of the active tab. Seems a simple enough problem at first (the appearance is modified using css) but I can't decide where to construct the menu.
Menu code:
<ul>
<li><a href="url1">item1</a></li>
<li id="active"><a href="url2">item2</a></li>
</ul>`
As I see it there are 3 choices of when to retrieve menu items:
- Upon receipt of HTTP Request to any controller for the first time store two arrays in the session - [url1, url2] and [item1, item2]. Then make the all the jsp pages form this into the above code. The jsp would have to know it's url to make against the [url1, url2] array in order to insert the active id.
- Create the above html separately in each controller. Since a controller knows it's own url, it's simple to add the active id.
- Create above html without any active id, store the html in the session and make either the jsp pages/controllers modify the html string.
None of these seem particularly appetising.
Does anyone have any advice on this?