aspose file tools*
The moose likes Struts and the fly likes Check User session when ajax aynchronous call is made Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Check User session when ajax aynchronous call is made" Watch "Check User session when ajax aynchronous call is made" New topic
Author

Check User session when ajax aynchronous call is made

Rashid Darvesh
Ranch Hand

Joined: Feb 13, 2004
Posts: 189
Hi All,
i have an application when a user selects a year it call the onChange method of the year combo and creates an xmlHttpRequest, assings a callback method (to render html when the request is complete) and call an action. The problem happens is when the user session is expired, i intercept the request in the mainactioncontroller, and it checks for the user session. and if it null it redirects the request to login.jsp page. But this is not happening and the controls comes back to the callback method to render the html and it results in some junk page. My architect suggested me to check in the call back method what is the req.responseText and set the req back to login.jsp page. Any idea what is hte most feasible way to handle this
Thanks
Rashid
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I'd suggest you have your action return some agreed upon value ("NOSESSION" for example) if the session has expired. In your JavaScript on the client side, you can then check for this value and cause the login JSP to be displayed:

location.replace("login.jsp");


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Check User session when ajax aynchronous call is made
 
Similar Threads
AJAX and Servlet question
calling servlet from ajax
Bean Problem
What does IE 8 Cache?
problem without logout, how to solve it