
The container receives a HTTP request.

The container creates request and response objects.

It initiates a new thread to handle the request. Then passes the two objects in to the thread.

Container calls the service() method of the servlet which would call the doGet() or doPost() methods, based on the request type.

The doGet() method returns the result, writes the HTML and stuffs it into the response object.


Container calls the service() method of the servlet which would call the doGet() or doPost() methods, based on the request type.

The doGet() method returns the result, writes the HTML and stuffs it into the response object.

The HTML page is sent back to the client, the response, request objects are deleted and the thread is killed.
Hope this would have given a clear picture on what happens to the request for a servlet. but still there is more. Here the business logic and presentation are tied together which is not a very good OO practice. you can separate them using JSPs.. MVC improves on it even more...We'll come back to that later..
Hope this would have given a clear picture on what happens to the request for a servlet. but still there is more. Here the business logic and presentation are tied together which is not a very good OO practice. you can separate them using JSPs.. MVC improves on it even more...We'll come back to that later..