This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Servlets and the fly likes How to get HTTP Session username? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to get HTTP Session username?" Watch "How to get HTTP Session username?" New topic
Author

How to get HTTP Session username?

Philippe Desrosiers
Ranch Hand

Joined: Mar 29, 2006
Posts: 138
I'm using FORM authentication under Tomcat 5. Everything works fine, but I'm trying to get the name of the logged in user, as it's stored in the session authentication. Is there a Principal, or Identity instance I can grab from the session in order to display the currently logged in user?
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
HttpServletRequest has the getUserPrincipal and getRemoteUser methods, which return this information.
Philippe Desrosiers
Ranch Hand

Joined: Mar 29, 2006
Posts: 138
Perfect! Thanks a bunch!
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: How to get HTTP Session username?
 
It's not a secret anymore!