• Post Reply Bookmark Topic Watch Topic
  • New Topic

security-role-ref with jsp

 
Mark Lybarger
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a jsp that does something like :

<% if (request.isUserInRole("emp") ) { %>

Emp Role Specific content here.

<% } %>

I need to map the emp role to a few actual roles. if the code was behind a servlet, i would map it with:
<servlet>
...
<security-role-ref>
<role-name>CodeMonkey-emp</role-name>
<role-link>emp</role-link>
</security-role-ref>
<security-role-ref>
<role-name>CodeMonkey-emp</role-name>
<role-link>emp</role-link>
</security-role-ref>

How can I do this same mapping with a .jsp?

thanks.

 
Stefan Evans
Bartender
Posts: 1822
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember a JSP gets translated into a servlet to be executed.
So if what you have there will work for a servlet, it will work just as well for a JSP.

You can define a servlet entry for a jsp in your web.xml as follows:


It is preferable to avoid scriptlet code in a JSP, so you might take a look at replacing the if statement with a custom tag to check if the user is in role.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!