Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Show user name on pages

 
P Arunkumar
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have the data stored in a scoped variable, simply use the EL to display the value.
 
P Arunkumar
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 671
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

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


Thanks & Regards,
Jenifer Rajkumar.
 
P Arunkumar
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just try this

Welcome ${userid}
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yogesh Gandhi,
Your post was moved to a new topic.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic