Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4380550
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:32:53+00:00 2026-05-21T12:32:53+00:00

My web app has a template that is used in all pages. I want

  • 0

My web app has a template that is used in all pages. I want to create a little label in that template (so it’s visible everywhere) to display the email of the user if it’s currently logged in.

I think the best way is to directly see if it exist on the session, so this is how I created the label:

<h:outputLabel id="usernameLabel"
               value="#{FacesContext.getCurrentInstance().getExternalContext()
                      .getSessionMap().get("userRole")}" />

The code is not syntactically correct. How can I write it in the appropriate manner to achieve my goal? Do you think this approach is correct?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T12:32:53+00:00Added an answer on May 21, 2026 at 12:32 pm

    The better approach would be to store userBean in session containing the user’s information.

    and then

    #{userBean.email}
    

    Or you can directly attribute from session using jsp el

    ${userRole}
    

    I would prefer first approach

    Update

    Upon successful login, set the frequently required in a ManagedBean for example

    @ManagedBean
    @SessionScoped
    public class CurrentUserInfo{
      private String userName;
      private String firstName;
      private String lastName;
      //and some other like DOB and etc..
      //+accessor methods 
    }
    

    This would be alive and accessible through the session

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm maintaining a web app that has performance problems. I want to record a
I'm using Bootstrap on a web app that has some pages that contain iframes.
I have a web app that has a big and complex form (fields, checks,
I have an existing web app that has a data layer and a bll
I have C# MVC web app that has some textboxes that in IE9 you
I'm developing a web app that has a database backend. In the past I'm
I'm building a new web app that has a requirement to generate an internal
I want to use the Model-View-Controller template while writing my Web App. The problem
I am building a Django powered web app that has a large database component.
My web app has been chugging along just great in Production for years with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.