This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Hi all I have one servlet ..i am creating an instance and i am accessing it... what will happen if another user tries to access it..(whether it uses intance pooling or multithread) If it uses pooling ,another user is going to get an instance from pool(a copy of instance as per my understading)..so if he finishes his work and leave will destroy() be called...if so won't it affect the original object.. Also i need a detailed explanation Pls priya
The servlet container (such as Tomcat) manages a single instance of your servlet. It is created the first time a request for that servlet occurs and it stays in memory. The destroy method gets called only when the servlet engine is shutting down or needs the space. There is no pool of servlet instances. The servlet container creates a new Thread for each request and many Threads may be running the same code "at the same time." User specific data is unique to that Thread. Therefore you have to change your programming habits that you may have used for single user applications. You can't use instance variables for user specific data. Many discussions here have touched on the problems, so browse around. Bill