The isCallerInRole on the EJBContext object can be used to test user roles, and the isUserInRole on the HttpServletRequest can be used to do the same in a servlet context.
There is no standard J2EE way to get the list of role of a user.
Am trying this as I need it in my web container not ejb...
But i get...
An error occurred at line: 10 in the jsp file: /artists/profile_form.jsp
Generated servlet error:
D:\jboss-4.0.0\server\default\work\jboss.web\localhost\mamoth\org\apache\jsp\artists\profile_005fform_jsp.java:52: cannot resolve symbol
symbol : variable getPrincipal
location: interface javax.servlet.http.HttpServletRequest
Sorry more specifically, I would like to know the username (PrincipalID) that is loged in to my web site, so i can use that PrincipalID to query the DB for additional information.
As sugested in the other post, request.getPrincipal.getName(), throws an exception as shown in the previous post.
I also wanted to do this through filter so I can create a bean and pass it along through a session, so i wont have to query the DB for the extra info again.
Agree, it was typed a little too quickly, but you should, at least, check the javadoc of the javax.servlet.http.HttpServletRequest class.
getPrincipal is a method, not a public instance variable (Java 101 ...).
Try request.getPrincipal().getName() instead.
in fact i looked at it through the eclipse code completion! and i didnt get the methodname getPrincipal!
But i will try this!
Still no go!