Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Generally, the server (Tomcat, Glassfish...) that hosts the web application handles a timeout for a session.</p> <p>For example, in Tomcat, you can define the session timeout for a particular web application by adding the folowing lines in the <code>web.xml</code> file:</p> <pre><code>&lt;session-config&gt; &lt;session-timeout&gt;30&lt;/session-timeout&gt; &lt;/session-config&gt; </code></pre> <p>This will set the timeout to 30 minutes.</p> <p>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.</p> <p>You can develop your own JSF Filter that will automatically redirect the user to a <code>timeout.html</code> page. Here is an example of such a filter :</p> <pre><code>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) &amp;&amp; (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 &amp;&amp; !request.isRequestedSessionIdValid(); } public void destroy() { } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload