Hi, Keep in mind that tomcat is a reference implementation of the servlet spec. I don't remember the servlet spec answering these questions, so tomcat isn't obliged to implement things any one way.
>1. Is it true that requests from the SAME client >always served by the SAME thread? Not always. Even if a servlet implements SingleThreadModel, the container may still keep a pool of instances of this servlet and issue requests as they come in, as long as no two requests share an instance at the same time (i.e. they'll process one at a time). >2. What if the SAME client access 2 different servlets >in a servlet container? Is it still served by the SAME >thread? Not always. >3. What happens if the client send another request >BEFORE the first request finished execution? Will the >second request queue up somewhere in servlet >container? Or it will be served by a different thread? If there's something that can handle this request, it will be handled independent of the first request. So it could get handled before the 1st request is done executing. >4. Is it recommend to use ThreadLocal when I write >Servlet code? Be very careful with ThreadLocal fields. I've seen a couple of very difficult to debug issues with using ThreadLocal. Whether you decide to use ThreadLocal in your design or not should not have to do with tomcat, as your code should be to the servlet spec as far as tomcat is concerned, and not to tomcat's particular implementation of things like the single thread model. This way you will be assured of container-independence should you need to change containers. Yoav Shapira Millennium ChemInformatics
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: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
