Check if HTTP Session is expired


To check if a HttpSession is invalid you can use this code:

boolean isSessionInvalid(final HttpServletRequest httpServletRequest) {
    final boolean sessionInValid = httpServletRequest.getRequestedSessionId() != null
        && !httpServletRequest.isRequestedSessionIdValid();
    return sessionInValid;
  }