Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Servlet get the logged in user name  RSS feed

 
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.)
 
Rancher
Posts: 3497
39
  • 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
Rancher
Posts: 3497
39
  • 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.
 
author & internet detective
Marshal
Posts: 38254
623
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
 
Author and ninkuma
Marshal
Posts: 66685
167
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)?
 
You know it is dark times when the trees riot. I think this tiny ad is their leader:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!