title: Tomcat's form based authentication with ajax app
body: <p>I use tomcat's form based authentication on a webapp which use most of the time ajax call.
  The configuration of the realm is pretty well documented, and it's working.</p>
  
  <p>My problem begin when the user's session is ended, for any reason.
  The subsequent ajax call will have a 200 ok response, with the content being the login page.</p>
  
  <p>I'm looking for a way to change the beavaior of tomcat, like sending a 401 instead of hiding the content, forcing a client redirect, or any other solution that let the JS script know that the session is over and authentication is required once again.</p>