• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to get username of currently logged user on client machine

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Start here: https://coderanch.com/how-to/java/ServletsFaq#security
reply
    Bookmark Topic Watch Topic
  • New Topic