Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Servlet get the logged in user name  RSS feed

 
Jayachandra Ch
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I deployed my servlet in server using tomcat. It basically have some input fields and save changes button. When someone writes something and click save I want to save changes to DB along with the PC name and logged user name of the client's PC. Everything is done till updating PC name and Username of client. I can get PC name by How can I get username? I tried many things such as (returns null, also returns null. How to change auth type?) and also tried (returns server username where as I need client username) and doesnt do the trick as well

(By username I mean the username by which logged in to PC.)
 
Dave Tolls
Ranch Hand
Posts: 2667
30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty sure that, outside of some authorisation mechanisms (and I can't actually think of one that would), that data is not passed in a request.
That would strike me as a security hole if that data was sent as a matter of course.  Who wants their login id for their machine being sent out?
 
Jayachandra Ch
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
am not sure about java but it can be done with asp.net, we can get data of the client
 
Dave Tolls
Ranch Hand
Posts: 2667
30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jayachandra Ch wrote:am not sure about java but it can be done with asp.net, we can get data of the client


Is that only if the client is a Windows box?
Is it doing windows based auth?

Essentially, the logged in user of a device is not a standard part of an http request header.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 36875
481
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jayachandra,
What are you using for login now? Some single sign on applications add a request header.

If you are looking for the username that was used to login to the computer, that's not available in Java.
 
Jayachandra Ch
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just want to get the pc's username who edits my servlet. If the username is there in DB it gives special privileges else it will skip. I dont need password (if at all we can do so), i need pc name and current logged in username in pc. Looking for any small procedure to achieve it. Thankyou
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65973
140
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not possible without a client-side agent (ActiveX, signed applet, etc).

So what do you expect to do if someone visits from a Mac? Linux? An iPhone? A Galaxy Note (before it catches fire)?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!