RE: Tomcat and Static Variables
Howdy, It claims that aliases (I may be wrong on this, it's hard to decipher the difference between JWS and Tomcat lingo) will create different instances to the target Servlet, but static variables are recognized. So access to one servlet instance might result in: The servlet container may (and tomcat does last I checked) create one instance of a (non-SingleThreadModel) servlet for every servlet tag in web.xml. So just have two servlet tags with different servlet-name but same servlet-class in your web.xml. You don't need two contexts for this. The question is how I can replicate the above behavior so static variables are spanned across more than one instance? Can anyone point me at a Tomcat scoping document? The tomcat scoping document is the Servlet Specification more or less ;) For things that are left up to the container implementation, you'll need to ask or better yet, read the code. Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat and Static Variables
The servlet container may (and tomcat does last I checked) create one instance of a (non-SingleThreadModel) servlet for every servlet tag in web.xml. So just have two servlet tags with different servlet-name but same servlet-class in your web.xml. You don't need two contexts for this. You nailed it right on the head. Thanks! I wonder aloud how Tomcat knows which class to use in any particular context (the server doesn't map to the Context), but maybe I'll just try it and see. So, to summarize...because I could find nothing on the topic anywhere and maybe this gets indexed somewhere...aliases and contexts do not map to different instances, server's do. The question is how I can replicate the above behavior so static variables are spanned across more than one instance? Can anyone point me at a Tomcat scoping document? The tomcat scoping document is the Servlet Specification more or less ;) For things that are left up to the container implementation, you'll need to ask or better yet, read the code. Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- - John Blanco - Code Guru @ Rapture In Venice - http://members.bbnow.net/jblanco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tomcat and Static Variables
I've got a book (extra credit to who can name it) which uses a Counter servlet as an example of how servlet containers handle static variables. It claims that aliases (I may be wrong on this, it's hard to decipher the difference between JWS and Tomcat lingo) will create different instances to the target Servlet, but static variables are recognized. So access to one servlet instance might result in: My Counter = 5, Global Counter = 8 While access to the other counter might have given you: My Counter = 4, Global Counter = 8 The global counter would be a count for the two instances combined (via the *static* field) and the my counter would be for the instance via a stanard fiield. I've tried pointing to the same WebApp via two different Context's, but the two apps are treated as completely separate, and the static variable doesn't hold. This is correct...two contexts should never interfere. The question is how I can replicate the above behavior so static variables are spanned across more than one instance? Can anyone point me at a Tomcat scoping document? -- - John Blanco - Code Guru @ Rapture In Venice - http://members.bbnow.net/jblanco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]