How to check if user has a specific role in JSP?

I need to make decisions in JSP based on user roles. Is there an EL tag or expression that allows me to do this?

+3
source share
1 answer

There is no built-in in JSP or JSTL, but the request taglib from the Jakarta project provides isUserInRole. Install taglib and use the tag as follows:

<req:isUserInRole role="admin">
 The remote user is in role "admin".
</req:isUserInRole>
<req:isUserInRole role="admin" value="false">
 The remote user is not in role "admin".
</req:isUserInRole>
+2
source

Source: https://habr.com/ru/post/1707842/


All Articles