Creating Dynamic Menus in JSP (Struts) according to User privilages

Hi,

Am new into Jsp and Struts... currently am assigned with a task to develop Jsp pages that will contain menus with respect to the privilages assigned to the user. There should be horizontal menus and vertical tree structured menus. We are paning to develop our Application on Struts Frame work with Hibernate Using the RAD 6.0. The user privilages should be taken from the database when the user logs in , according to the privilages the menus should be shown...

Please provide with some suggestions on how to implement this... we have no idea how it should be done. we have our menus done in HTML and javascript. But how to implement them using struts html tags in JSP?.

Please can any one suggest on how we should proceed on implementing this feature?

Thanks and regards

Rens

[818 byte] By [Rens@New2JAVAa] at [2007-11-26 20:05:50]
# 1

you will have to create a arraylist in the servlet , which you will call in the jsp , this arraylist should fetch you the result , i am sending you some what similar approach, hope you get what i want to say .

ArrayList clientList = new ArrayList();

while(rs.next())

{

ClientData client = new ClientData();

client.setName(rs.getString("name"));

client.setTestimonial(rs.getString("testimonial"));

client.setCompany(rs.getString("company"));

clientList.add(client);

}

this code is for the servlet where ClientData is the class where all the get set methods have been declared .

Now moving to the jsp side you need to call this arraylist

this is how you can do it.

<%

ArrayList clientlist = (ArrayList)request.getAttribute("clientlist");

Iterator empIt = clientlist.iterator();

while(empIt.hasNext())

{

ClientData client = (ClientData)empIt.next() ;

String name = client.getName();

String testimonial = client.getTestimonial();

String company = client.getCompany();

%>

and you can use the values anywhere in the jsp like <%=company>

you will also have to close the while loop

<%

}

%>

Varun_Rathorea at 2007-7-9 23:07:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Thanx for your Reply...

But still my doubt is not cleared.

I am having Tables in database with privilages and menu items that should be shown for each privilages, so i can get the menu items that needed to be displayed according to the privilage of the user who's logged in. So this part is clearfor me.

these are the things that worry me

1) Once i get the menu items, i need to display it in the Struts JSP page... thats a dynamic process. How to do it.. i cant use any scriplets or too much java Scripts in my page and i need to follow a standerd page template for showing menus.

2) For each menu item there will be a link to another page, there may be some actions also asscociated with each link that should be invoked on clicking these links. so i need to generate menus dynamically and also associate those links with pages and actions too dynamically.

how to approach this problem. ?

Is there any solution with JSTL since i cant use any JSP Scriplets and too many Javascripts?

Rens@New2JAVAa at 2007-7-9 23:07:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...