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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:02:23+00:00 2026-05-12T15:02:23+00:00

I have a JSF app and would like to have the user auto logout

  • 0

I have a JSF app and would like to have the user auto logout after a period of inactivity. Is there an standard way to do this?

  • 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-12T15:02:23+00:00Added an answer on May 12, 2026 at 3:02 pm

    Generally, the server (Tomcat, Glassfish…) that hosts the web application handles a timeout for a session.

    For example, in Tomcat, you can define the session timeout for a particular web application by adding the folowing lines in the web.xml file:

    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
    

    This will set the timeout to 30 minutes.

    When a user does not send any request during a time greater that this defined timeout, the session on the server is invalidated. If the user tries to reconnect after the session has been invalidated, he will generally be redirected to another page or to an error page.

    You can develop your own JSF Filter that will automatically redirect the user to a timeout.html page. Here is an example of such a filter :

    public class TimeoutFilter implements Filter { 
    
        private static final String TIMEOUT_PAGE = "timeout.html"; 
        private static final String LOGIN_PAGE = "login.faces";  
    
        public void init(FilterConfig filterConfig) throws ServletException { 
        } 
    
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { 
        if ((request instanceof HttpServletRequest) && (response instanceof HttpServletResponse)) { 
            HttpServletRequest requestHttp = (HttpServletRequest) request; 
            HttpServletResponse responseHttp = (HttpServletResponse) response; 
            if (checkResource(requestHttp)) {
                String requestPath = requestHttp.getRequestURI();
                if (checkSession(requestHttp)) { 
                    String timeoutUrl = hRequest.getContextPath() + "/" + TIMEOUT_PAGE; 
                    responseHttp.sendRedirect(timeoutUrl); 
                    return; 
                } 
            } 
            filterChain.doFilter(request, response);
        } 
    
        private boolean checkResource(HttpServletRequest request) { 
            String requestPath = request.getRequestURI(); 
            return !(requestPath.contains(TIMEOUT_PAGE) || requestPath.contains(LOGIN_PAGE) || requestPath.equals(hRequest.getContextPath() + "/")); 
        } 
    
        private boolean checkSession(HttpServletRequest request) { 
            return request.getRequestedSessionId() != null && !request.isRequestedSessionIdValid(); 
        }
    
        public void destroy() { 
        } 
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small JSF app and would like to keep some state on
I have JSF code like: <h:inputText id=from value=#{fromToMBean.fromName}/> I would like to get this
I have a JSF app on GlassFish. It's designed like so: user.xhtml > UserHandler.java
I have a JSF application that uses mostly Richfaces. I would like to introduce
I have this JSF page trying to load a GWT app. The page works
Is there a way to make jsf validator handle empty strings? I have a
I have a JSF 2.0 application that I would like to start adding validators
I would like for my app to redirect users encountering a JSF ajax error
I have a simple JSF web app as follows. The Java class contains: private
I have the following 3 simple pages in a JSF app. index.html start.html confirmSuccess.thml

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.