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 6380035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:12:55+00:00 2026-05-25T02:12:55+00:00

I have a simple authorization page which intends the user to type login and

  • 0

I have a simple authorization page which intends the user to type login and password. Based on the results of user input, I define the next page to display. I have a table in db that contains id, user’s login and password, and user’s role, so the next page will be defined based on information that will be retrieved from the role field of the record which corresponds to inputed login and pass. But also I have a table in db which contains all of the user’s info(about 10 fields) of one type of users and another table which contains info about another type of users(4 fields). So my db has such a structure:

Table 1:
  id
  login
  pass
  role

Table 2:
  id(reference to id of table 1)
  other fields....

Table 3:
  id(reference to id of table 1)
  other info....

I think that my app has to have a managed bean(requestScope) for authorization that will take login and password. That bean will have an action controller for submitting authorization form. In that action controller I have to determine the role of user and based on that information create a session scoped managed bean for concrete type of user(app will have separate managed bean for different types of users). Also I have in that action controller to pass specific info for instatiation the session scoped bean for user(id of user). But can I simply instatiate a session scope managed bean(with help of new operator) in action method of request scope managed bean? Also how can I use methods of one session scoped bean in another session scoped bean(Suppose I create 2 session scoped managed beans which are responsible for different services, how can i call method of one in another).
Maybe the described method isn’t good for such a problem? If so can you give an advise for better design approach?

  • 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-25T02:12:56+00:00Added an answer on May 25, 2026 at 2:12 am

    Accessing one managed bean from another

    To answer this directly, you normally use @ManagedProperty to inject one managed bean in another managed bean. Yes, it will auto-create the beans, but that should be particularly cheap.


    But can I simply instatiate a session scope managed bean(with help of new operator) in action method of request scope managed bean?

    Yes, that’s possible. Just store it in ExternalContext#getSessionMap() with the managed bean name as key.

    ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
    ec.getSessionMap().put("bean", new Bean());
    

    It’ll be available by #{bean} and so on. Whether that’s a good approach is a second.


    As to your concrete functional requirement. I think it’s much better to have just a single session scoped managed bean with the desired data as properties. You could then for example just check if the User property is not null to determine if the user is logged in. You can find a bean example in this answer: Programmatically control login with Servlet 3.0.

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

Sidebar

Related Questions

I have simple form. <form target=_blank action=somescript.php method=Post id=simpleForm> <input type=hidden name=url value=http://...> <input
I have a login script that verifies a username/password against data in a 'user'
I have simple SSIS package which reads data from flat file and insert into
I have simple SSIS package in which On Error event handler I have created
I have an MVC 2 application that every page requires authorization on (except currently
I'm trying to build a simple user authorization system where a .txt file stores
I have a pretty simple profile page where users can upload images and videos.
My application is simple, I have 2 pages: RSSProducer.aspx: A page that generates RSS
I have simple regex \.*\ for me its says select everything between and ,
I have simple win service, that executes few tasks periodically. How should I pass

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.