Kaleeswaran Karuppasamy wrote:in normal servlet when client calls it will call service mothod..this service method concurrently executed by multiple threat..here is my doubt....when service method executed each and every thread will get its own object of servlet or single servlet with same service method...of single instance mean...how servlet responce to different client....suppose there is the chance two thread enter into service method and suppose i am authenticate thread 1 at the same time the username has changed by thread 2 means everything will fail..please answe my question
There will be a single instance of the Servlet, and all requests will share this single instance while using its own Thread.
Because of this, it is important that SErvlets do not maintain their own (instance or static) state as this will be visible to all threads and shared between them, possibly allowing one thread to read or overwrite data from another request. This is bad.
Variables in methods are safe, as there is a separate copy of the variable for each thread.
In your case I believe it is sufficient to make sure you avoid storing state in the servlet.
/Dave