• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Show user name on pages

 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just try this

Welcome ${userid}
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yogesh Gandhi,
Your post was moved to a new topic.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic