[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2006-03-21
4
Medium Priority
?
186 Views
Last Modified: 2010-04-01
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
0
Comment
Question by:KirtipurItagol
  • 2
  • 2
4 Comments
 
LVL 11

Assisted Solution

by:fargo
fargo earned 800 total points
ID: 16251133
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
0
 
LVL 23

Accepted Solution

by:
Siva Prasanna Kumar earned 1200 total points
ID: 16256611
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.
0
 
LVL 23

Assisted Solution

by:Siva Prasanna Kumar
Siva Prasanna Kumar earned 1200 total points
ID: 16256663
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.
0
 
LVL 11

Expert Comment

by:fargo
ID: 16258142
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
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Tech giants such as Amazon and Google have sold Alexa and Echo to such an extent that they have become household names. And soon they are expected to be used by commoners in their homes, ordering takeout, picking out a song, answering trivia questio…
Integration Management Part 2
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month17 days, 23 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question