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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:55:08+00:00 2026-06-17T11:55:08+00:00

I don’t redirect or forward my user to another page. So when the my

  • 0

I don’t redirect or forward my user to another page. So when the my SessionExpiredExceptionHandler (extends ExceptionHandlerWrapper) handles the ViewExireException. I want the user to stay on the same page and display a PrimeFaces Dialog. For notifying that the session has expired and that the user needs to login again (dialog based). I am use Servlet 3.1 functions to login/logout user and Basic/file for auth-method to map the users to different system roles.

What is happening now is that the View/page get refreshed after 2 min, but the session doesn’t get invalidated. That only happens the second time when the page refreshes, after 4 min.

    <session-config>
        <session-timeout>2</session-timeout>
    </session-config>

Edit:
Which is refreshed by the meta tag:

<meta http-equiv="refresh" content="#{session.maxInactiveInterval}" />

How can I make SessionExpiredExceptionHandlerinvalidate the session object (Servlet logout) when the Exceptions occur the first time, and how can I invoke a JavaScript (expireDlg.show()) on the client to display a PrimeFaces dialog ?

I have looked at some other threads but not found a viable solution.
Session time-out

SessionExpiredExceptionHandler

    @Override
    public void handle() throws FacesException {
    for (Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();) {
        ExceptionQueuedEvent event = i.next();
        ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
        Throwable t = context.getException();
        if (t instanceof ViewExpiredException) {
        ViewExpiredException vee = (ViewExpiredException) t;
        FacesContext fc = FacesContext.getCurrentInstance();
        Map<String, Object> requestMap = fc.getExternalContext().getRequestMap();
        NavigationHandler nav = fc.getApplication().getNavigationHandler();                

        try {
            requestMap.put("currentViewId", vee.getViewId());

            nav.handleNavigation(fc, null, "Home");
            fc.renderResponse();

        } finally {
            i.remove();
        }                                
        }
    }
    // At this point, the queue will not contain any ViewExpiredEvents.
    // Therefore, let the parent handle them.
    getWrapped().handle();
    }

web.xml

<exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/home.xhtml</location>
</error-page>
  • 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-17T11:55:09+00:00Added an answer on June 17, 2026 at 11:55 am

    This solution worked for my case. It seams that Primefaces (3.3) is swallowing the ExceptionQueuedEvent. There are no Exception to handle when my ViewExceptionHandler gets called. So instead I used the p:idleMonitor component with event listner. I also removed the meta refresh tag.

    <p:idleMonitor timeout="#{(session.maxInactiveInterval-60)*1000}">
            <p:ajax event="idle" process="@this" update="sessionMsg" listener="#{userController.userIdleSession()}" />
            <p:ajax event="active" process="@this" update="sessionMsg" listener="#{userController.userActiveSession()}"/>
    </p:idleMonitor>
    

    One weird thing is if the timeoutis excatly the same as the web.xmlsession time-out parameter, the listener won’t be invoked.

    Bean functions

    public void userIdleSession() {
        if (!userIdleMsgVisable) {
            userIdleMsgVisable = true;
            JsfUtil.addWarningMessage(JsfUtil.getResourceMessage("session_expire_title"), JsfUtil.getResourceMessage("session_expire_content"));            
        }
    }
    
    public void userActiveSession() {
            if (!userSessionDlgVisable) {
                userSessionDlgVisable = true;                     
                RequestContext.getCurrentInstance().execute("sessionExipreDlg.show()");            
            }
        }
    

    The dialog (sessionExipreDlg) called the redirect instead of using navigation handler to get new scope and refresh the page.

    public void userInactiveRedirect() {
            FacesContext fc = FacesContext.getCurrentInstance();
            userIdleMsgVisable = false;
            userSessionDlgVisable = false;
            sessionUser = null;         
            HttpServletRequest request = (HttpServletRequest) fc.getExternalContext().getRequest();
            JsfUtil.findBean("homeController", HomeController.class).clearCurrentValues();        
            try {
                fc.getExternalContext().redirect(JsfUtil.getApplicationPath(request, false, null));            
            } catch (IOException ex) {
                BeanUtil.severe(ex.getLocalizedMessage());
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't want my user to even try downloading something unless they have Wi-Fi
Don't these two mean the same thing, first get the value and then increment?
Don't know is it possible to copy elements from one map to another map
don't understand: in my controller: @json = User.all.to_gmaps4rails do |user| \Title\: \#{user.email}\ end in
Don't want to pay for dedicated server for dev work. I don't want to
Don't get me wrong, I want them to get saved. But I always thought
Don't want to sort the entries. using this does not preserve the order as
don't know better title for this, but here's my code. I have class user
Don't know if I'm using the not selector incorrectly but I want everything clicked
Don't know if I worded the question right, but basically what I want to

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.