• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get username of currently logged user on client machine

 
Shobhit Khandelwal
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In my jsp, I require cuurently looged in username in one of the textbox and for this I am using System.getProperty("user.name") but when I access the application from some other machine(client) then this still shows username of logged In user on server. I want this field to be change according to the client machine userId everytime.
Kindly suggest the possible ways.

Thanks
Shobhit
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That property will always reflect the user on the server, so it's no use for what you're trying to do.

Is this a web app for which a login is required? If so, you could use ServletRequest.getRemoteUser for this.
 
Shobhit Khandelwal
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes this is a web app but login is not needed and so is the requirement given to me.
Is there any other way to deal with this?
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your most likely chance of success would be to have an applet which gets that system property from the client and somehow sends it to the server.
 
Shobhit Khandelwal
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Thanks for your replies. I got the solution of this problem in javascript. For those who don't want login page or credentials to be filled by the client, I am providing my javascript function here :

We can access any win32 class through javascript like this and can get whatever system propeerty we want. I mean if it is accessible through cmd then it can be done through javascript like above code.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you didn't say that a solution that works only on one particular browser on one particular operating system was acceptable. That's generally not the case with web applications (and actually defeats a large part of their purpose).
 
Shobhit Khandelwal
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ulf, I got your point. Yes, I admit that this code is operating system(windows) and browser specific(IE and not sure about other browsers)
 
Anwarul Yaseen Shahul Hameed
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:That property will always reflect the user on the server, so it's no use for what you're trying to do.

Is this a web app for which a login is required? If so, you could use ServletRequest.getRemoteUser for this.

Can you give some example to use ServletRequest.getRemoteUser
 
Ulf Dittmer
Rancher
Posts: 42968
73
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic