• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

security-role-ref with jsp

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic