Background: client request starts a long-running procedure which eventually returns a calculated result. I want to provide a progress meter so that the user knows that the request is still running. The page where this happens periodically fires an AJAX request to sample the progress of the procedure which is generating the response to the original request. The code which handles the original request adds a session attribute which references an object that knows how to get the current value of "progress". The code which handles the AJAX request looks up this session attribute to provide its response. The first AJAX request fires one second after the original request, confirmed by examining the application's log.
This all happens in a single instance of Tomcat 8.5.55 using the StandardManager with all its default settings, i.e. there is no Manager element in the configuration. I don't require persistence across restarts. Problem: the attribute is definitely being created by the original-request handler, because I can see its name in the enumeration returned by Session.getAttributeNames in that handler after setting the attribute, and it definitely has a value there. However, one second later, in the AJAX-request handler the same Session (yes, I checked the session IDs and they match) does not contain an attribute with this name, though it contains all of the other attributes that were enumerated in the original-request handler. The object referenced by the attribute does not implement Serializable and it would be difficult to do so. But it doesn't seem to me that this is necessary in the circumstances: not clustered, not using PersistentManager. Where did I go wrong? I'm considering other ways to coordinate the two requests, but I'd like to know why this one isn't working. Possible confounding factor: this is a Cocoon 2.2 application, and the HttpSession in both handlers is actually an org.apache.cocoon.environment.http.HttpSession. But I'm accessing the attributes the same way in both handlers -- I actually copy/pasted my debugging code -- and the session shows my attribute in one but not subsequently in the other. Bonus question: this AJAX activity isn't going to have any effect on whether the original request times out, is it? So I probably need a broader re-think. (All the traffic is proxied through Apache HTTPD via AJP.) -- Mark H. Wood Lead Technology Analyst University Library Indiana University - Purdue University Indianapolis 755 W. Michigan Street Indianapolis, IN 46202 317-274-0749 www.ulib.iupui.edu
signature.asc
Description: PGP signature