2 Replies Latest reply on May 14, 2008 7:33 AM by Viktor Rees

    SessionId within @Destroy method

    Viktor Rees Newbie

      How can I get the sessionId inside of an @Destroy method?

      The following code doesn´t work because FacesContext is null. I believe reason is that there is no client request when the session expires? 

      public void destroy() 
           FacesContext facesContext = FacesContext.getCurrentInstance();
           ExternalContext externalContext = facesContext.getExternalContext();
           HttpSession session = (HttpSession) externalContext.getSession(true);
           String sessionId = session.getId();
           AppData appData = (AppData) Component.getInstance("appData");
           log.debug("removed: " + sessionId );

      appData.getLoggedInSessions() is an application scoped Map
      of Session information.

      Is there an other way to get access to the sessionId?