• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session Management with Ajax

 
Satish Dasari
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have a problem with session management with ajax requests. In my application I'm using struts1.2.9 and hibernate 3.
In my usecase I've to check the user existance in session. If user exist in the session then it should get into the application, if not it should redirect to login page.
I used filter to check the session existance and redirecting the request to the login page if user doesn't exist.

But here my problem is in my application there several ajax requests are there.
For every request its checking for the session and if the session doesn't exist its redirecting to the login page.
everything working fine with normal requests. But when any ajax request occurs the login page is loaded in a specific "DIV" .

So instead of loading the entire page , some divs only getting loaded with the login page.

i don't know how to solve this problem.
My code is given below


and my web.xml form mapping is



Thanks in advance

Regards,
Satish Raj.

 
Ankit Garg
Sheriff
Posts: 9519
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't show us the AJAX code. Anyways, in your AJAX code, try to see the response's status code. If the status code of the response is 307 (or anything between 300 and 399), then that means that the AJAX call was redirected. Then you can redirect the page in JS using location.href and the Location header of the response. Similar examples can be seen here and here...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic