I want do display a login link when the user isn’t logged in and a logout link when the user is logged in. I’m using container managed security as defined in web.xml.
How can I achieve this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The username of the logged-in user is available by
ExternalContext#getRemoteUser()which delegates under the covers toHttpServletRequest#getRemoteUser(). Both are available in EL by#{facesContext.externalContext.remoteUser}and#{request.remoteUser}respectively. If it isnull, then it means that the user is not logged in.So, in your view you can check it in the
renderedattribute as follows:See also: