aspose file tools
The moose likes Servlets and the fly likes difference between HttpServletRequest's getUserPrincipal and getRemoteUser Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "difference between HttpServletRequest Watch "difference between HttpServletRequest New topic
Author

difference between HttpServletRequest's getUserPrincipal and getRemoteUser

Abdul Rahman
Ranch Hand

Joined: Jul 04, 2008
Posts: 62
Hi,

Can anyone explain me the difference between HttpServletRequest's getUserPrincipal() and getRemoteUser().

As per the api,

getRemoteUser(): Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.
getUserPrincipal: Returns a java.security.Principal object containing the name of the current authenticated user.

The Principal class has a method getName() that returns the name of the principal.

I would like to know under what scenarios these two methods of HttpServletRequest should be used and why.

The reason why i ask is because i need to get the userid of the user who has logged into the application. The application i'm developing is not a dummy application. It is to be used by real people in real scenario. so i need to know the feature of these two methods before i use any one of them.

Thanks


Abdul
SCJP5, SCWCD5, [scwcd wall of fame]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: difference between HttpServletRequest's getUserPrincipal and getRemoteUser
 
Similar Threads
Form Based secruity...
getRemoteUser and getUserPrincipal()
HELP - Question on Tomcat Connector ISAPI Filter for authentication on IIS
Modifying a request using a Servlet Filter
Windows UID