I am making ajax calls from my JS methods to invoke the action class's methods in the following manner:
$.getJSON("treeDemo_!getRootNode?appId=" + applicationId, function () {
}).success(function (e) {
}).error(function (jqXHR, textStatus, errorThrown) {
alert(textStatus);
}).complete(function () {
});
Session configuration in my web.xml looks like this
<session-config>
<session-timeout>1</session-timeout>
</session-config>
Now when the session expires after 1 minute, the ajax call returns error (without calling the action method). The error says
textStatus = parsererror
errorThrown = SyntaxError: JSON.parse: unexpected character
But this looks like a generic error. I want to catch the session timeout exception and redirect the user to the login.jsp page in case this exception occurs.
I even tried handling it by doing this. But it didn't work for me.
Can you please suggest how should I solve it?