I'm looking for the function to verify if the user logged belongs to a role. is maybe the following?
pageContext.request.userPrincipal.roles
How should I use it properly along with JSTL to test if the user belong to ADMIN group?
You can use the Method expression 'pageContext.request.isUserInRole' in JSP to check whether the current authenticated user has a role.
Test this:
<c:if test="${not empty pageContext.request.userPrincipal}">
<c:if test="${pageContext.request.isUserInRole('ADMIN')}">
User ${pageContext.request.userPrincipal.name} in ADMIN Group
</c:if>
</c:if>
Notes:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>