Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

windows username (difference when run in java and jsp)

Status
Not open for further replies.

dexter195

Programmer
Jun 18, 2003
220
0
0
EU
Hi,

Im creating a small internal web application that will detect the user's username automatically to save them having to log in and out and also to restrict other people accessing the application.

when i run the following code in java

Code:
System.getProperty("user.name")

it brings up the windows username.
however when i put this on a jsp page it brings up SYSTEM and when i use the code

Code:
System.getProperty("user.home")

to bring up their home directory it works in java but in the jsp it brings up one of the administrators accounts which isnt being used. this admin account cannot be removed.

does anybody have any ways around this?

thanks for the help
 
Hi

That will not work that way. I suppose your servlet container is started as a service, that is why you get SYSTEM as user.name. If you start the servlet container from the command window, the returned user.name will be the name of the user who started it.

You did not mentioned your servlet container's name, neither the used/desired authentication method. So no suggestion for now. Give us more details.

Feherke.
 
thanks feherke,

i wasnt aware of the servlet container had anything to do with authentication. i just used the servlet-api.jar

%CATALINA_HOME%\common\lib\servlet-api.jar;


i have that in my CLASSPATH environmnet variable. i presume that, that's started up with the tomcat service. or is this the servlet container that your talking about?

thanks

 
Im creating a small internal web application that will detect the user's username automatically to save them having to log in and out and also to restrict other people accessing the application.

I'm not folowwing you. That property shows the user running the server application in the server machine. I take you want to store the user name of the client machine. Am I wrong?

Cheers,
Dian
 
thats exactly what i want to do dian. i guess i should have copped that. ill have a look to see if some java script can do the job.

cheers
 
Hi

Dian said:
I take you want to store the user name of the client machine.
dexter195 said:
thats exactly what i want to do
I hope that will be never possible for a server-side web application to find out the name of the user on client side.

A way could be with some signed Java applet, which with the user's acceptance could have access to local machine's stuffs...

Why not a simple password based authentication ?

Feherke.
 
Asumming its an Intranet application and security is not an issue, you could do that using JavaScript. The Javascript forum is plenty of examples with different ways:
After that you can send the username as a parameter and process it server side.

Cheers,
Dian
 
I can see your point but this is for an internal application within the company so i suppose a signed applet is probably the way to go.

the reason i dont want a password based authentication is becasue i want as little maintance as possible. i dont want to have all the bother with people loosing passwords. if their using their machine then il take it that they're that person. security isnt really an issue but its more that i want to restrict the site to a certain bunch of people. ill give the applets ago and see how i get on.

thanks for advice
 
It it's an internal application, the I imagine it will be placed on a trusted server. That means there's no need of signed applets as the server will placed in the trusted sites of the browser.

Cheers,
Dian
 
Thanks for the help. Im gona have to resort to the usual username and password because after talking to the people who'll be using the site, they'll need to access the information from other peoples workstations so if i go this way they'll have no permissions when they're on other peoples pcs so sorry to have bothered ye.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top