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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:49:21+00:00 2026-06-15T04:49:21+00:00

In my attempts to find out the reason for the problems stated in this

  • 0

In my attempts to find out the reason for the problems stated in this question: JSF2 slow page loading, I would like to time a user session filter I use. I’ve created a timer that is an ApplicationScoped bean.

My question is if it’s possible to access this bean as a managed property from the filter. In my other beans I can do this, although in the filter the managed property is always null.

  • 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-06-15T04:49:23+00:00Added an answer on June 15, 2026 at 4:49 am

    Updated Answer:

    Access your application scoped bean from filter in the follwoing way

    ServletContext context = req.getServletContext();
    MyAppBean myAppBean = (MyAppBean) context.getAttribute("myAppBean");
    

    Access your session scoped bean from filter in the following way

    HttpSession session = ((HttpServletRequest) req).getSession(false);
    MyAppBean myAppBean = (MyAppBean ) session.getAttribute("myAppBean");
    

    Original Answer :

    Yes you can , make it (eager = true) , and add the needed annotations

    @ManagedBean(eager = true)
    @ApplicationScoped
    public class MyAppBean { }
    

    and in your sesion scoped bean access it like this

    @ManagedProperty(value = "#{myAppBean }")
    private MyAppBean myAppBean; //add getter and setter
    

    If your bean is not a @ManagedBean you can access it from the ApplicationMap like this

    MyAppBean myAppBean = (MyAppBean ) FacesContext.getCurrentInstance().
        getExternalContext().getApplicationMap().get("country");
    

    If the bean you want to access is a @SessionScoped you can grab it from the SessionMap like this

    MyAppBean myAppBean = (MyAppBean ) FacesContext.getCurrentInstance().
        getExternalContext().getSessionMap().get("country");
    

    Here you got some nice tutorial on how to access beans from a non managed beans

    Access A Managed Bean From Event Listener – JSF

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

Sidebar

Related Questions

I would like to find out and keep track of the 'line number' (rows)
We would like to give our users the option of filtering out profanity .
In my attempts to find out how to start a new intent in my
This code attempts to dynamically switch the class of the StateContainer div from StateOne
This code attempts to resize images in a directory called imgs. Unfortunately for some
After a number of failed deployment attempts (configs overwritten, files missing, out dated etc)
I was searching the web for my question and couldn't find a clear answeror
I've been googling this all day with out finding the answer, so apologies in
Ok guys, just a quick question hopefully someone can find my mistake quickly, but
I am sorry if it seems like I am posting the same question. The

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.