wood burning stoves
The moose likes JSP and the fly likes Problem in with Tomcat 5.0 to run jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Problem in with Tomcat 5.0 to run jsp " Watch "Problem in with Tomcat 5.0 to run jsp " New topic

Problem in with Tomcat 5.0 to run jsp

ranjeet amancha

Joined: Dec 17, 2008
Posts: 5

Im using Tomcat 5.0 to run my jsp which contains the code to get windows username.

out.println("Username : "+System.getProperty("user.name"));
out.println("Username : "+System.getenv("username"));

Output of the above code is
Username : SYSTEM Username : null

If I use the same code is run using Tomcat 5.5 then I get correct output.

I also came to know that If I use System.getProperty("user.name"); in a java class then I get correct output(No need of Tomcat).

But in my application I got to use JSP. I even tried for calling java method(which returns username with System.getProperty())in a JSP, after that also I get the wrong output.

Can any one tell me why Im getting this problem?
Is this problem related to versions of Tomcat?

Thanks in advance
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
No, it's not a problem related to Tomcat.

You expected the Java code to run at the client machine, but it doesn't. It runs at the server machine. That's your misinterpretation here.

If you want to get the client's user name by System.getProperty(), then you obviously need to run Java at the client machine. You can do this using a signed applet or a web start application.
jQuery in Action, 3rd edition
subject: Problem in with Tomcat 5.0 to run jsp
It's not a secret anymore!