javatomcatj-security-check

How to check if a user is logged in when using auth-method FORM


I am using auth-method FORM with apache tomcat to authenticate users. I am using the default j_security_check action.

If a user has signed in, I must display a Sign out link. Else a sign in link. How do I check if the user has signed in?

Also, how do I log a user out?


Solution

  • You can use HttpServletRequest.getUserPrincipal() and check it to find the logged in user.