• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Session Timeout on Ajax Calls

 
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I configure an interceptor/filter in my spring mvc apps that will redirect my user to the Login Page if their session is already expired.

Now, I used jquery ajax in getting some of the data. I also configure a global error handler
should there be a problem.




My problem here is that, I see in my firebug that there is a 302 HTTP status but what happens is that, my Login Page gets appended into my error content.

I checked the exception in the ajaxerror handler and it says "invalid json"

What I want is that if session already expired then user gets redirected to the login page for all ajax calls.

I am not sure how to check for session timeout when using ajax calls. Can somebody give me advice on this?

Thanks.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Personally, I'd say it's risky to attach an Ajax error handler *after* you've made an Ajax request.

If you need to handle a specific response code then you should code a handler just for that error code; there are a variety of ways to do that.
 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Personally, I'd say it's risky to attach an Ajax error handler *after* you've made an Ajax request.



I rearrange my code and place my ajax error callback above the document ready function. Is this the correct way of having a global
error callback on ajax request? Thanks for your thoughts..



I added also below code, to trap the 302 HTTP response code but I think it's not working though.
I always get an xhr status of 200.



But I see in my firebug that I get a 302 response but I think my firefox browser is handling this on its own. In the end, my login page gets appended into my
errorcontent div and I see an invalid json on the exception.

If you need to handle a specific response code then you should code a handler just for that error code; there are a variety of ways to do that.


Can you give me an idea please on how to properly trap the HTTP response of 302?

Thanks
 
You got style baby! More than this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic