If you invoke any serverside program in an Ajax call it doesn't refresh the entire page with the resoponse. So in the webapplication using ajax call needs special treatment to track the session time out and refresh the entire page to forward to login page.
Following is one special scenerio where an j2ee application using Struts framework implements the session time out issue.
1. Check if the session is valid for the user
2. If the session is timed-out, return to a particular action mapping forward (e.g. 'session-time-out')
3. In the struts-config.xml, forward the session-time-out to a special jsp page (e.g. ajaxSessionTimeOut.jsp) which will contain a particular value that represents the session time out
4. In the call back object/method of the ajax call, parse the value from the responseXML. If the parsed value is the value set in the forwarded page (i.e. ajaxSesssionTimeOut.jsp), set the action of the form to the login.do (the action mapping for the login in the application) and submit it
The similar technique, shown above, can be used in any other web applicatoin.