I have a database set up that Tomcat can communicate with and perform authentication.
Problem: $ {userRole}
in a JSP does not seem to work properly. It appears that $ {userRole}
evaluates correctly to ‘user’ and ‘admin’ when those are the role entries in the database for the user in question. However, if the role is anything else, e. g. ‘abcd’, then the role evaluates to ‘user’.
Below is a list of user’s role in the database and what $ {userRole}
evaluates to in the JSP:
role in db $ {userRole} in jsp 1234 user adm user abcd user user user admin admin
Why does $ {userRole}
not evaluate correctly when the role is something else than user and admin? Is $ {pageContext.request.isUserInRole('roleName')}
the only way to make decisions based on role assignments?