Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

security-role-ref with jsp

 
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.

 
Bartender
Posts: 1845
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.
 
    Bookmark Topic Watch Topic
  • New Topic