To get windows username Im using the following code.
Expand|Select|Wrap|Line Numbers
- public class GetWindowUsername {
- public String getUser() {
- String userName = System.getProperty("user.name");
- System.out.println("Window's Username: "+userName);
- return userName;
- }
- }
- public class TestUserName {
- public static void main(String args[]) {
- GetWindowUsername g = new GetWindowUsername();
- String s = g.getUser();
- System.out.println("UserName : "+s);
- }
- }
But when I use it in jsp like-
Expand|Select|Wrap|Line Numbers
- <%
- String s = System.getProperty("user.name");
- out.println("Windows Username : "+s);
- %>
" Windows Username : SYSTEM "
I tried to call the "getUser()" in jsp using an object of "GetWindowUsername"
but even after that I got same output.
Im running the above jsp using Apache Tomcat 5.0 on my server machine.
When I run the same code on my local system using eclipse & Apache Tomcat v5.5, I get the output correct.
Can anyone solve my problem.
Thanks in advance
Tiijnar