Reading some book that said the servlet is singleton from the container side. Is this true?
However even it is a singleton, we need to handle data synchronization etc
Reading some book that said the servlet is singleton from the container side. Is this true?
However even it is a singleton, we need to handle data synchronization etc
Servlet can be initialized as a single instance or a pool of instances.
Here is an extract from <<Java Platform, Enterprise Edition The Java EE Tutorial Release 7>>:
A web container will typically create a thread to handle each request. To ensure that a servlet instance handles only one request at a time, a servlet can implement the SingleThreadModel interface. If a servlet implements this interface, no two threads will execute concurrently in the servlet's service method. A web container can implement this guarantee by synchronizing access to a single instance of the servlet or by maintaining a pool of web component instances and dispatching each new request to a free instance.