View Full Version : Expired user not prompt with login page

26 Sep 2011, 11:22 AM
When an user session is expired and user clicks on a link, my server re-direct this Ajax request to the login page http://localhost/login.html, then the Ext JS client try this link, and the server responded with

HTTP/1.1 304 Not Modified
Server: Apache-Coyote/1.1
ETag: W/"2079-1316725105548"
Date: Mon, 26 Sep 2011 16:38:26 GMT

This may make sense from server point of view since the login page content is not changed. But because of client is not on login page, and I guess this "Not Modified" response made client do nothing instead of showing any buffered login page if there is any, the login page is not popped up as expected.

Any suggestion how should I handle this?

27 Sep 2011, 12:26 AM
Common problem.

If you redirect from an Ajax request it won't cause the entire page to be redirected in the browser, it'll just redirect that request. This often leads to errors as the success handler for an Ajax request is rarely expecting an HTML login page.

Rather than sending back a redirect you should send back a response that can be understood by your Ajax handlers and they should do the redirect manually. One technique that allows centralized handling on all Ajax requests is to use the requestexception event:


A little care needs to be taken as this will fire for all errors, not just expired logins.

An alternative is to specify a failure handler for the individual request though this is usually not as good an approach.

27 Sep 2011, 1:43 PM
Thanks Skirtle for the detailed answer. Everything you said makes sense to me. I was expect Ext would be able to handle re-directed URL though.
I get other tasks in hand and will not be able to try it out soon. With your details here I don't expect any big trouble to implement it. Thanks again!