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

Posted on 2006-03-21
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?
Question by:KirtipurItagol
    LVL 11

    Assisted Solution


    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

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

    LVL 23

    Accepted Solution

    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.
    LVL 23

    Assisted Solution

    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


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

    LVL 11

    Expert Comment


    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.


    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    logging jar 1 100
    Coldfusion 10 - JSP File Not Found - 404 Error 5 59
    java operators 3 72
    instanceof  operator in java 26 57
    Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
    Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now