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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:13:54+00:00 2026-05-27T16:13:54+00:00

I have JSF web app on glassfish using j_security_check validation with jdbcRealm on glassfish

  • 0

I have JSF web app on glassfish using j_security_check validation with jdbcRealm on glassfish connected to MSSQL db.
Is there any way to check for example if there exists active bean with given username?
I just want to display on the web page who is online. My guesses:

  1. keep variable in database and change it with login/logout. The problem rather occurs if someone didnt logout but his session expires. Than I don’t have possibility to check if he’s still logged in.
  2. keep boolean variable in bean and change it with login/logout. Problem is as in previous opportunity.

Is there way to change such variable while session expires? Maybe some other approach is more common?

  • 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-27T16:13:55+00:00Added an answer on May 27, 2026 at 4:13 pm

    The problem rather occurs if someone didnt logout but his session expires. Than I don’t have possibility to check if he’s still logged in.

    You have the possibility by implementing a HttpSessionListener:

    @WebListener
    public class YourUserSessionListener implements HttpSessionListener {
    
        @Override 
        public void sessionCreated(HttpSessionEvent event) {
            // NOOP.
        }
    
        @Override
        public void sessionDestroyed(HttpSessionEvent event) {
            YourUser yourUser = event.getSession().getAttribute("yourUser");
    
            if (yourUser != null) {
                yourUser.logout(); // Update DB.
            }
        }
    
    }
    

    Where YourUser is your session scoped JSF managed bean representing the logged-in user.

    Or when you’re on JSF2 (as your question history confirms), put @PreDestroy on the logout method in the session scoped JSF managed bean representing the logged-in user:

    @ManagedBean
    @SessionScoped
    public class YourUser {
    
        // ...
    
        @PreDestroy
        public void logout() {
            // Update DB.
        }
    
    }
    

    This way the method will be invoked before the bean get destroyed on session expiration.

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

Sidebar

Related Questions

In a simple demo web app using JSF 2 and Ajax, there is a
I have a Java-JSF Web Application on GlassFish, in which I want to use
I have a J2EE/JSF-based web-app. It consists of an form-input, a text display and
I am using a JSF 2.0 to create a web app (purely jee6, without
Im working in a Web App with Java and JSF. I have a simple
I have a small web application developed using Icefaces 1.8.2 and jsf 1.1 which
I'm developing a web application using Java EE6 and JSF 2.0. I have a
I have a large non-Java EE, JSF-based web app project. Our system is layered
I am building web app using Casssandra DB & Java with JSF 2.0 .
I have a web app using JSF2 with JPA Entities, Stateless ejb session beans

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.