System.getProperty() on the server

Asked

Viewed 393 times

0

In my code I use System.getProperty("user.name") to get the local username. But I would like to use my application on a server. And by spinning it instead of returning what previously returned locally, it is returning "root".

I believe that it is returning the "username" of the server, or of my own machine but of the user Admnistrador. My question is: It is possible for me to get it even if I run the application from System.getProperty("user.name") to get it from the user you have accessing from the server?

If you’re not using System.getProperty(), there is some other way?

  • When running your application on a server, which username you want to return?

  • The same that returns when I run on my machine. I am logged in with a network user, for example "R12345". I would like you to return this same user.

  • 1

    Good, System.getProperty(), as the name already says, it will take the system, if you want to see the client name, you must make it authenticate or pass this name by parameter in the request to the server.

1 answer

2


Documentation

The class System maintains an object Properties that describes the current desktop configuration. This object is initially populated by JVM, you can specify additional parameters using the -Property=value flag

In your case then, the JVM has set the user as root. To be easy to understand, imagine that System.getProperty("user.name") is running on the server side and not on your machine.

If you want to get the current user, you can opt for a signed applet or javascript (although in this I’m not sure if there is a portable way to get this information).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.