I want to get logged username on windows , I mean the user logged in to windows using java. I used System.getProperty("user.name"); but I got the server-name, not the user.
1 Answer
Getting the name of the user logged into your web application (which I think is what you want to do, based on your comments) entirely depends on how you have implemented authentication in your system. However, if your login mechanism adds this information, the username might be available in request.getRemoteUser() or request.getUserPrincipal(). But as mentioned, it all depends. Your authentication mechanism might expose this otherwise, but then we would need more information to assist.
System.getProperty("user.name") will only give you the username of the user running the java process.
user.nameis the name of the account that is logged into the computer.System.getProperty("user.name")will give you user logged on server machine.<object>element in the produced HTML. This way the webbrowser will download and run it in its own (sandboxed!) environment.