Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

difference between HttpServletRequest's getUserPrincipal and getRemoteUser  RSS feed

Abdul Rahman
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 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.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!