title: Get Session Status with Jquery
body: <p>In my application, I would know when the session has expired by doing Ajax calls every 30 seconds, but the problem is that when I can controller method, HttpSession refresh and lastaccessedtime changed.
  So have you any idea how to know the status of the session without changing it's behaviour.
  I'm using Jquery and SpringMVC 2.5</p>
  
  <pre><code>@RequestMapping(value = "/consultForm.htm", params = "verifySession", method = RequestMethod.GET)
  public ModelAndView verifySessionStatus(WebRequest webRequest, Model model, HttpServletRequest request, HttpServletResponse response) {
      boolean isValid = true;
      HttpSession session = request.getSession(false);
      if (session.getAttribute("user") == null) {
          isValid = false;
      }
      ModelAndView modelAndView = new ModelAndView("jsonView");
      model.addAttribute("sessionValid", isValid);
      modelAndView.addObject(model);
      return modelAndView;
  }
  
  
  $.ajax({
      url : "search.htm?verifySession=1",
      type : "GET",
      async : false,
      cache : false,
      success : function(data) {
  
          valid = data.sessionValid;
          if (!valid) {
              showPopinExpire = true;
              $("#dialog-session-expired").dialog("open");
          }
      },
      error:function (xhr, ajaxOptions, thrownError){
          alert(xhr.status);
          alert(thrownError);
      } 
  });
  </code></pre>
  
  <p>Even with <code>request.isRequestedSessionIdValid()</code>, everytime I call controller method, the session was refreshed.</p>
  
  <p>Thank you</p>