This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Spring and the fly likes displaying selective tabs in JSP based on access rights Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Spring
Bookmark "displaying selective tabs in JSP based on access rights" Watch "displaying selective tabs in JSP based on access rights" New topic
Author

displaying selective tabs in JSP based on access rights

Shiny Suresh
Ranch Hand

Joined: Feb 03, 2011
Posts: 31
Hi,

I have a task. I have a few tabs in Jsp, while clicking on each, takes to different page. I need to display the tabs based on the rights that a logged in user's role has. For eg, if the user does not have the right to update, the update tab should not be displayed. I would appreciate if any one could give me an idea about how to do it.

Thanks,
Shiny.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

Conditionals in a JSP can be easily handle with the JSTL tags <c:if>, or <c:choose> with c:when> and <c:otherwise>.

Or, the controller can send a list of the tabs to be displayed to the page based upon the user rights.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Shiny Suresh
Ranch Hand

Joined: Feb 03, 2011
Posts: 31
Thanks for the prompt response. I will try it.

Shiny Suresh
Ranch Hand

Joined: Feb 03, 2011
Posts: 31
Hi,

I am supposed to be displaying based on the user's rights using Spring's <security:authorize> tag.



I have this right AUTHORITY_GENERAL_INQUIRY. But still the tab does not get displayed. I tried changing ifAllGranted to ifNotGranted, the tab displays.
How do I check what authorities the user has? We use ldap for authentication and authorization.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1652
    
    7

Well for starters the tag you are using are deprecated.

https://github.com/SpringSource/spring-security/blob/master/taglibs/src/main/resources/META-INF/security.tld

I would go ahead and start using access




You can check the stuff you are asking about server side, maybe in your controller.



[How To Ask Questions][Read before you PM me]
Shiny Suresh
Ranch Hand

Joined: Feb 03, 2011
Posts: 31
Hi,

Thanks for your response. I did a workaround, by using <c:if > and checking the permissions. Probably <security:authorize> didn't work for me because it is deprecated, like you said.
Appreciate your help.

Thanks,
Shiny.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: displaying selective tabs in JSP based on access rights