Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Get Remote Username in Java Servlet  RSS feed

 
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
 
Rancher
Posts: 43009
76
  • 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.
 
Bartender
Posts: 20773
124
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • 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.
 
It's weird that we cook bacon and bake cookies. Eat this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!