Java – ICEFaces Session Auto-Extension


I have an application in which users frequently leave the page running in their browser all day. The page has an intervalrendered that updates data every 30 seconds.

However, if the user doesn't interact with the page for a while, it still expires. I'd like it to auto-extend for as long as the browser is open and making the scheduled requests.

Is there a way to automatically extend the session everytime that the scheduled renderer is fired for one of these pages?

Best Solution

I don't really want to do Javascript hacks to click buttons when my code is already being called every 30 seconds by ICEFaces. The following hacked workaround for ICEFaces internal timer seems to work:

  private void updateSessionExpiration () {
      HttpSession sess = getSession();
      if (sess != null) {
        try {
            Field fld = SessionDispatcher.class.getDeclaredField("SessionMonitors");
            Map map = (Map)fld.get(null);
            String sessID = sess.getId();
            if (map.containsKey(sessID)) {
      "About to touch session...");
                SessionDispatcher.Monitor mon = 
        } catch (Exception e) {
            log.error("Failed to touch session");

Also, with ICEFaces 1.8.2RC1 (and presumably eventually with the release version of ICEFaces 1.8.2 as well), there are two new workarounds available:

HttpServletRequest request = (HttpServletRequest) servletRequest; 
HttpSession session = request.getSession(); 
if (session != null) { 

Or, put this in the web.xml to update on any hit to URLs within a specific pattern:

    <filter-name>Touch Session</filter-name> 
    <filter-name>Touch Session</filter-name> 
Related Question