tags:

views:

119

answers:

1

Hey everybody,

is there a way to get the logged in user name (and group) from a Tomcat system. I read something about configuring Tomcat, so it is getting the user information out of a database. But I found now information about getting the name of the user (in my GWT Project), which is logged in.

I'm trying to write a little GWT project and would like to publish the user name to the front page.

Thx for your help.

A: 

You can try these two methods from the HttpServletRequest interface.

getUserPrincipal() returns a Principal from which you can get the logged used as getUserPrinicipal().getName().

isUserInRole("Administrators") returns true if the current Principal is in the provided role.

Of course this only works if you are using tomcat realm authentication found here.

rmarimon
thx. that worked for me.
wolfi