• Post Reply Bookmark Topic Watch Topic
  • New Topic

Get Remote Username in Java Servlet

 
Viswanath Thulluru
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a servlet. Users from other machines access that servlet and I want to capture the remote user's UserName and do validation over that.
It's just a simple servlet and no login/password is present. I tried request.getRemoteUser(), but its of no luck.
Can some one help me with a solution.

Thanks,
Viswanath
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getRemoteUser is the correct method, but it can only work if the user has logged in. If there is no login, then there is no user.
 
Tim Holloway
Bartender
Posts: 18408
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to clarify, "logged in" means that the user has logged into the webapp's J2EE standard security system. A LAN login, such as a Windows login, only counts if the webapp server has been configured to hook into Windows LAN security.

Likewise, if you write your own login system or use one the the samples that too many books on J2EE provide, the getRemoteUser() method will just return null. You have to actually use the J2EE standard.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!