when a client request something the request is directed to the container.the container makes two objects,which are
- request object
- response object
the thread comes in to action in one of the two ways mentioned below.
- a thread pool provides one of the threads it have
- a new thread is created(new Thread();)
then the service() method redirect the request to a relevant method which may be doGet() or doPost() according to the request. we will learn about these methods in future.
after executing one of these methods the generated response is directed to the browser by the container.and the threads work is also over.
so the thread goes to dead state if it is a newly created one and it will go back to pool if it was taken form the thread pool.
now there is no need of the request and response objects.so they are eligible for the garbage collector to be collected.
and when the servlet is no longer needed the destroy() method of the servlet is called and the servlet moves to the dead state.this is also called only once.
**for every request we make a new thread comes to the action.**
No comments:
Post a Comment