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

  • SEARCH
  • Home
  • 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 6162893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:44:02+00:00 2026-05-23T21:44:02+00:00

I have a session scoped managed bean with name ‘usermanager’. i want to store

  • 0

I have a session scoped managed bean with name ‘usermanager’. i want to store user information which is newly logged in , in a property of usermanager bean and access it using static metod below. I want to ask these questions ,thanks in advance and sorry for poor english.

1-A managed bean is managed if i get it throught jsf injection mechanizm.That is if i create a instance using new UserManager() this will not be a managed bean .Am i right?

2-In what conditions usermanager in code below can be null.

3-What is the most efficient way of handling user,group permissions in java .Should i use Spring ,Seam for this purpose.

4-Should i store this user info in Httpsession with setParamater(key,Object) or continue to store it in a session bean.

  public static User getUserOfCurrentSession(){
         UserManager userManager = (UserManager) ((HttpServletRequest)FacesContext.getCurrentInstance()
                .getExternalContext().getRequest()).getSession(true)
                .getAttribute("userManager");

         if(userManager!=null){
             return userManager.getUser();
         }
        FacesContext c = FacesContext.getCurrentInstance();
        HttpServletRequest r = (HttpServletRequest) c.getExternalContext()
                .getRequest();
        HttpSession s = r.getSession(false);
        if(s!=null)
          s.invalidate();
        try{
        FacesContext.getCurrentInstance().getExternalContext().redirect("login.xhtml");
        FacesContext.getCurrentInstance().responseComplete();
        return  null;
        }catch(IOException e){
            e.printStackTrace();
        }
        throw  new RuntimeException("Un authonticated  user action");
    }
  • 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-23T21:44:03+00:00Added an answer on May 23, 2026 at 9:44 pm
    1. Yes, you are right. You must leave JSF instantiate the bean for it to be managed
    2. If there is no session attribute (or bean) called userManager. But you better get this instance through injection.
    3. There is no “most efficient way”. It depends on your requirements. I have often done it manually, because it was simple enough. If it is more complex – spring security is said to be good (though I’m reserved).
    4. It goes in the session either way, so prefer the bean.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSF session scope bean and I'm keeping current user(logged in) information
I have a session scoped managed bean, with a property current . If I
I have a session bean <managed-bean> <managed-bean-name>vdcAddBean</managed-bean-name> <managed-bean-class>com.cloud.appsportfolio.jsf.vdc.beans.VDCAddBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> Now, I am injecting
i have an managed bean(session scope) like this: class Home {// as homeBean public
I have a Session scoped bean @SessionScoped public class UserData implements Serializable { private
Is it possible in JSF 2 to initialize a session-scoped managed bean as soon
I want to ask if i place my managed bean in session scope, then
I have this managed bean which takes two values from database's table import java.io.Serializable;
I have a managed bean which gets list of settings and values from database
I have a managed bean declared in session scope. There is a drop down

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.