tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Chaney <>
Subject Re: Retrieve User Role
Date Thu, 08 Jan 2009 22:40:25 GMT
Hi Ben

You can get it from the request. In JSP you can access the request 
implict object to get the value of the 
HttpServletRequest#getRemoteUser() method ...

"Returns the login of the user making this request, if the user has been 
authenticated, or null if the user has not been authenticated."

(quote from j2ee docs for HttpServletRequest)

The exact syntax to use depends upon whether or not you are using EL.
If you are using tags..
<% String username = request.getRemoteUser() %>

and in EL you can use the 'pageContext'. Try:

${pageContext.request.remoteUser}   /// I think... you may need to check.

and use as you see fit...


Ben Tomlinson wrote:
> I have set up login security for some of the pages in my website.  I
> have a JDBCRealm setup and working correctly.  But now I want to
> change the layout of my pages (all jsp pages) according to the user
> that is logged in.  How do I retrieve information about the user that
> is actually logged in?  Mainly I want the user role or the user name
> but I can't seem to get it from the session.  Any help would be
> appreciated.
> Ben
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:
> !DSPAM:49667e4a164556657853550!

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message