Name
<ora:ifUserInRole>
Synopsis
The <ora:ifUserInRole>
action tests if the user authenticated for the request belongs to the
specified role. If so, its body is evaluated, or the Boolean test
result is saved in the specified variable. Note that this action
works only with container-provides authentication, using the security
roles declared in the application deployment descriptor.
Syntax 1: Conditionally evaluate the body
<ora:ifUserInRole value="roleName
"> Evaluated if the current user belongs toroleName
</ora:ifUserInRole>
Syntax 2: Saving the test result
<ora:ifUserInRole value="roleName
" var="var
" [scope="page|request|session|application"] />
Attributes
Attributename |
Java type |
Dynamic valueaccepted |
Description |
---|---|---|---|
value |
String |
EL expression |
The role name |
var |
String |
No |
The name of the variable |
scope |
String |
No |
Scope for the variable |
Example
<%-- Evaluate the body if the current user belongs to the "admin" role --%> <ora:ifUserInRole value="admin"> You're an admin </ora:ifUserInRole> <%-- Save true in the isAdmin variable if the current user belongs to the "admin" role --%> <ora:ifUserInRole value="admin" var="isAdmin" />
Get JavaServer Pages, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.