How can I check if a user is logged in using jsf?
This is how I am doing it and it’s not working:
<ui:fragment rendered="#{!request.getUserPrincipal().getName().equalsIgnoreCase('anonymous')}">
<h:outputLink value="logout">
<h:outputText value="Logout" />
</h:outputLink>
</ui:fragment>
Just check if
HttpServletRequest#getUserPrincipal()is notnull.It also works for
HttpServletRequest#getRemoteUser().