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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:22:53+00:00 2026-06-02T19:22:53+00:00

As I was told and found on websites, my bean will only be executed

  • 0

As I was told and found on websites, my bean will only be executed if I have a call for it on my .xhtml.

Is it possible to call my bean without any EL expression?

I need this because my HomeController is calling a method that checks for the session status and on my home.xhtml and don’t have any need for fall this bean, for now.

  • 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-02T19:22:54+00:00Added an answer on June 2, 2026 at 7:22 pm

    You need to look for a solution in a different direction.

    If you’re homegrowing user authentication instead of using container managed authentication, then you normally use a servlet filter for the particular purpose of checking if an user is logged in or not.

    The servlet filter can like as servlets (like FacesServlet) be mapped on a particular URL pattern. It will then be invoked on every request matching that URL pattern. You can explore request/session data in the filter and then handle the request/response accordingly by either continuning the filter chain, or by sending a redirect.

    You need to implement javax.servlet.Filter interface accordingly. Here’s a kickoff example of how the doFilter() method should be implemented assuming that you’ve a @SessionScoped managed bean LoginController. JSF stores session scoped managed beans as attributes of HttpSession.

    @Override
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) req;
        HttpServletResponse response = (HttpServletResponse) res;
        HttpSession session = request.getSession(false);
        LoginController loginController = (LoginController) (session != null) ? session.getAttribute("loginController") : null;
    
        if (loginController == null || !loginController.isLoggedIn()) {
            response.sendRedirect(request.getContextPath() + "/login.xhtml"); // No logged-in user found, so redirect to login page.
        } else {
            chain.doFilter(req, res); // Logged-in user found, so just continue request.
        }
    }
    

    Map this filter on an URL pattern covering the restricted pages, e.g. /app/*.

    @WebFilter("/app/*")
    public class LoginFilter implements Filter {
        // ...
    }
    

    Update if the login.xhtml is also covered by this URL pattern and you really can’t change it, then change the if block as follows:

    if (!request.getRequestURI().endsWith("/login.xhtml") && (loginController == null || !loginController.isLoggedIn())) {
        // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been told to edit this file in Sharepoint Designer: /_layouts/KWizCom_WikiPlus/CreateNew.aspx I found
I recently found an article online that told me about this: RewriteRule ^mock-up/([^/]+)/([^/]+) /mock-up/index.php?page=$1&section=$2
Someone told me that openGL is for graphic only, and that it's very bad
I was just told that I might have to work on a project where
Some people have told me that the following code is bad for HTML validation:
Perhaps I haven't found the right post but I have been unable to set
I am looking for a regular expression that will accept date formats, both MM/DD/YYYY
I have been told that the Provider pattern is a way to design loosely
I have been told that Singletons are hard to test. http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars/ http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/ I have
i have a website which is basically a omegle copy ( text version only

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.