This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi Guys This is probably an embarrassingly easy question, but I'm a bit confused. Essentially my question is: Does tomcat execute all its different sessions in the same JVM? So if I had a Singleton class Foo, would session A and session B both return references to the same object? I'm trying to implement some simple cacheing and so on to save on multiple db hits. Any thoughts gratefully received! Alister
In general yes, but if you use multiple hosts (virtual hosts) or if you use clustering, there will be multiple instances of the JVM running, and your singleton will only be unique to each instance. For cases like these, you'll have to use some sort of database repository if you only want one instance of something represented accross multiple hosts/clusters.
Joined: Sep 13, 2002
Thanks for that. It's what I thought was the case, but I'm glad to be reassured! No, there won't be clustering et al. When the system gets big enough to require that, I'll shift it onto EJBs and make it all someone elses problem! Alister