File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Session Management with Ajax Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Session Management with Ajax" Watch "Session Management with Ajax" New topic
Author

Session Management with Ajax

Satish Dasari
Greenhorn

Joined: Dec 10, 2008
Posts: 2
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

Joined: Aug 03, 2008
Posts: 9303
    
  17

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...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
GeeCON Prague 2014
 
subject: Session Management with Ajax