This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Servlets and the fly likes servletContext getting the name of the user that's logged in Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "servletContext getting the name of the user that Watch "servletContext getting the name of the user that New topic
Author

servletContext getting the name of the user that's logged in

Jeroen Nouws
Greenhorn

Joined: Jul 14, 2011
Posts: 17
Hey,

i'm looking to get a username from a person that loggs in,
i heard you can get it from the servletContext, but don't know what method to look for
can anyone help me on my way?

cheers
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63208
    
  69

That greatly depends upon what you mean by "logged in".


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jeroen Nouws
Greenhorn

Joined: Jul 14, 2011
Posts: 17
i've found what i was looking for in the request.getRemoteUser();
with logging in i meant supplying a username and password to access a restricted area
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63208
    
  69

Right -- which will only work if you use container-managed authentication (as it appears you are). Not everyone does, so it's important to point that out.
 
Have you checked out Aspose?
 
subject: servletContext getting the name of the user that's logged in
 
It's not a secret anymore!