Want to display the name of the user in my JSP form!

Hi Experts, I'm using JSP for my form and struts as a framework. In each JSP page i want to display the user's name as soon as the user logins(such as welcome "User Name") , it will take him to another page and so on, but each page should display that line ----> Welcome "user name".
But the problem is, each user logs in with the pin number instead of the actual name...How to tackle this problem?
Bhaskar
KirtipurItagolAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fargoCommented:
Hi,

when the user logs in, can you get the user_name information from the database?

Say suppose, you get the user_name information from database, you can then keep this user_name in session.

Moreover for all the pages, you can either use some kind of template like Sitemesh
http://www.opensymphony.com/sitemesh/
OR

you can have a jsp which gets included in all the jsps.

regards,
fargo
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
yes i agree with fargo,

You just need to get the username from the datbase based on th login in pin.
later set it as a session attribute & use it for dispalying the name in all the JSPs but just using a session.getAtttibute.

and also the idea of using a local include in all files just to diaplay username sounds good too as it will avoid lots of code duplication as the name is being displayed in all the JSPs.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
And one more thing please do a null check before displaying "Welcome User" else it come like "Welcome Null" i had seen one such thing in a major website so i don't want you to get something like that.
try have code some thing like

Welcome
if(session.getAttribute("USERNAME")!=null)
{
<%=session.getAttribute("USERNAME")%>  
}
,

so tht this shows the user name like "Welcome shiva," or just "Welcome,".

thanks.
fargoCommented:
Hello,

This is really not fair. You put me into the assisted answer, while mine is the one who answered your question.
shivaspk has just repeated my comments.

fargo
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.