Something in the thread creates one of those objects, or more likely is given one of them by the container, and then calls its service method. Of course this would be done as part of the something's run() method.
It isn't a singleton in the sense that it's guaranteed there will only be one instance of each servlet in the container. On the other hand the container will probably only create one instance of each servlet, unless it's forced to create more. So no, it isn't one instance per thread.
Container 's Thread instances representing the request processing thread may contain an instance variable "HttpServletRequest"... When request is received, container may create an instance of HttpServletRequest and assign this instance to one of request processing thread from the Thread Pool...
Likewise, for each request processing thread instance, HttpServletRequest instance is assigned to get request processed.
I had similar doubt. Instead of posting a new topic, I am asking here.
Well, I didn't completely understand this sentence: "The Container finds the correct servlet based on the URL in the request, creates or allocates a thread for that request, and calls the servlet’s service() method, passing the request and response objects as arguments."
Allocation of a thread and calling servlet's service() method: is service() method called inside the allocated thread's run() method? That means, the thread will call the service() method right? If thread doesn't call service() method, then what is the use of allocating a thread?
"The Container finds the correct servlet based on the URL in the request, creates or allocates a thread for that request, and calls the servlet’s service() method, passing the request and response objects as arguments."
Above lines explains the flow of request and response for a web app.Check your Deployment Descriptor(web.xml).Your app's web.xml is the access point for the request to reach the correct servlet it is ment for.
Once container gets a request ,it maps the URL in in web.xml as servlet mapping and assign a thread to the request .This thread accesses service method of the matching servlet which takes request and response as the arguments.
Thats one of the many roles of the container.
If the servlet class file gets loaded thread will call the service method other wise container will not able to find the correct servlet and will throw ClassNotFound.And assigned thread is ment for calling the service method which depending upon the type of request calls doGet or doPost .