File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes How to get environment variable? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "How to get environment variable?" Watch "How to get environment variable?" New topic
Author

How to get environment variable?

Rekha Pai
Ranch Hand

Joined: Oct 30, 2008
Posts: 35
Hi,

Root is running the tomcat server.
In my jsp page if I use the System.getProperty("user.name")
it gives user name as "root".

How can I get the user name who has opened the page?

Regards,
Rekha
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

You can't. The container knows about himself, his environment, his applications, incoming requests... It doesn't know about the thousand users unix/windows/other account accessing its applications.

You have to make a proper web authentication system in your application to identify your users.


[My Blog]
All roads lead to JavaRanch
Rekha Pai
Ranch Hand

Joined: Oct 30, 2008
Posts: 35
Hi,

Then is it possible to get the user name from the browser's user profile?

Regards,
Rekha
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

What's a browser's user profile ? Don't forget that JSP is server-side.
Rekha Pai
Ranch Hand

Joined: Oct 30, 2008
Posts: 35
Hi,

Ok, My requirement is poping up an alert which is
user dependent. I can use cookies for that. But javascript and html page
can not give me user data. How can I do that?

So once a person logs in and opens a browser is there any way to capture
his user id?

Regards,
Rekha
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

No. As I said, you have to make a proper login mechanism in your application.
Rekha Pai
Ranch Hand

Joined: Oct 30, 2008
Posts: 35
Thanks a lot.

Regards,
Rekha
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

I had already told you this in the other post that you opened. Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place. Please click this link ⇒ CarefullyChooseOneForum ⇐ for more information.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get environment variable?