aspose file tools*
The moose likes JSP and the fly likes Show user name on pages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Show user name on pages" Watch "Show user name on pages" New topic
Author

Show user name on pages

P Arunkumar
Ranch Hand

Joined: Jan 05, 2012
Posts: 119
i wants to show the user name in every jsp page after a particular user login for this what what method i can use.

Please Reply me.

Thanks & Regards,
Jenifer Rajkumar.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60997
    
  65

If you have the data stored in a scoped variable, simply use the EL to display the value.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
P Arunkumar
Ranch Hand

Joined: Jan 05, 2012
Posts: 119
Hi


Iam new to developing side, so please guide me with simple example.

My query is after we giving user id and password to Login, the particular user name wants to show in every page of my jsp page, i gave link to 10 pages, after i clicking every link username of a particular user wants to appear.


Thanks & Regards,

Jenifer Rajkumar.
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 510

Bear, already gave you an answer, let me put in once again.
After, the user logs in, store his/her name in the session. Then, in JSP you can use EL, to retrieve it.


Regards, Prasad
SCJP 5 (93%)
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

It isn't difficult.

When you find out what the user ID is, add it to the session as a scoped variable. Like this:

(where userID is the variable containing the user ID).

Then on any JSP where you want to display the user ID, you use the EL to display that scoped variable:
P Arunkumar
Ranch Hand

Joined: Jan 05, 2012
Posts: 119
Hi

Thank you so Much, Realy its so help full for me. I got the Result.


Thanks & Regards,
Jenifer Rajkumar.
P Arunkumar
Ranch Hand

Joined: Jan 05, 2012
Posts: 119
Hi


If i use EL method only the user name is showing is i want to show like Welcome "username", what method i want to use,

I tried in EL itself but iam getting error, and with java code with this username as variable also its shows error.

But after login, in second page with java code its coming,remaing page its shows error. if i use EL its showing only username i can't add some words with it.

My first page code
out.println("<CENTER> <b>Welcome </b>"+username);
but its not working in all page.

please help me,

Thanks & Regards,
Jenifer Rajkumar.
Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 207
Just try this

Welcome ${userid}
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60997
    
  65

Scriptlets in JSP pages have been discredited for 10 years now! 10 years.

You should not be using any Java code in your JSP pages. Time to catch up and stop writing JSP pages like it is still 2002.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60997
    
  65

Yogesh Gandhi,
Your post was moved to a new topic.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Show user name on pages