code: public HttpSession generateNewId(WebApp webapp) {
          HttpSession existingSession = (HttpSession) webappToSessionMap.get(webapp);
          if (existingSession != null) {
              if (!webapp.getSessionContext().isValid(existingSession, request, false)) {
                  existingSession = null;
              }
          } else {
              // Looks like the session wasn't obtained during the preinvoke
              // call.  Should only happen if session doesn't exist at preinvoke.
              existingSession = webapp.getSessionContext().getIHttpSession(request, (HttpServletResponse) request.getResponse(), false);                
          }
          if ( existingSession == null) {
              if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled()) {  
                  Tr.error(tc, "changeSessionId.no.session.associated.with.request", new Object[] {request.getRequestURI()});
              }
              throw new IllegalStateException(Tr.formatMessage(tc, "changeSessionId.no.session.associated.with.request", request.getRequestURI()));
          }
          
          HttpSession session = ((HttpSessionContext31Impl)webapp.getSessionContext()).generateNewId(request, (HttpServletResponse) request.getResponse(), existingSession);
          
          return session;
      }
docs: Added for support of HttpSessionIdListeners