Chris's Wiki :: blog/web/NonpersistentStateSimple Commentshttps://utcc.utoronto.ca/~cks/space/blog/web/NonpersistentStateSimple?atomcommentsDWiki2014-10-08T18:43:41ZRecent comments in Chris's Wiki :: blog/web/NonpersistentStateSimple.By Jeremy on /blog/web/NonpersistentStateSimpletag:CSpace:blog/web/NonpersistentStateSimple:462822645f3df0d643b58bcce46a5ec0dc4d5c73Jeremy<div class="wikitext"><p>In java, it kind of depends on the web framework you're using. You can of course access global variables (aka static variables) but only if you are deployed on a single jvm that doesn't shut down. That sort of thing is not recommended.</p>
<p>The servlet api provides explicit access to request, session and global scoped data. In theory, a servlet container can distribute an application across any number of jvms as long as it propagates the session and global state around.</p>
<p>Synchronization for concurrent requests within the same session is tricky. Afaik, modifications to session or global scoped data is immediately visible to requests being processed on the same machine, but changes would only be propagated between jvms at the end of each request. I don't think any explicit locking primitives are provided to prevent overwriting, but I haven't looked at this stuff in a long time.</p>
<p>As far as I understand, this is similar to php sessions, which may be serialized to disk and re-loaded when a new php interpreter is fired up, or even just between requests, in case there are more active sessions than can be kept in memory.</p>
</div>2014-10-08T18:43:41Z