Java – Servlet: Singleton, Singlethread or Multi Instance Multithread

javajspservlets

This question has been asked previously and discussed before but i want to ask it further.

  1. Are Servlets Singleton or not ?
    According to me they are initialized only by the container but they are still not singleton ?? why ??

  2. Are Servlets Single Thread or multi Threaded (Forget about javax.servlet.SingleThreadModel class)
    i.e. What happens when there are multiple requests for a single servlet ??
    If they are executed conncurrently, that means it is multi threaded ??
    and if its multi threaded then each thread will have an instance of the servlet, which contradicts with the 1st point !!

What i think is,
Whenever theres a new request, The container creates a new Thread for the incoming Request say Req1, in that it calls or dispatches the control to the service method of servlet. Now this execution happens concurrenlty.. i guess so…

Does my working stands the same in a MVC envirionment ?? (say Struts 1/2, Springs)

Best Answer

The fact that exists just one instance doesn't means it isn't multithread. More thread can concurrently call tha same method of the same instance. Servlets are absolutly multithread.