Now-a-days everything is available in Internet. Starting from e-banking, e-commerce everything is available through internet. And we call all these applications as Web applications. In the previous blog we have seen Basics of Web Application, in which we had seen about Server also. In this tutorial we will see how server provides dynamic response with the help of Servlet Container. Also we will see how Servlet Container works.
Server is the one which gets the client request and find the appropriate response for that request. Here the response is nothing but static content. Yes, server won’t do any processing of request to provide dynamic response to the client.
In order to provide dynamic response, server will take a help of Servlet Container/ Web Container.
How Servlet Container Works
Before explain what a servlet container is, let’s see this pictorial representation of what a servlet container is.
- Initially when the request come to server and if the client is asking for dynamic response the server will forward the request to Servlet Container.
- The Servlet Container will read the xml file and decide for which Servlet it has to transfer the request.
- Once Servlet container decided to which Servlet it has to transfer the request, first it will create one servlet request and response object and create a thread for that servlet and invoke service()
- The doGet() or doPost() method generate the dynamic response and give it to container and the container will give to server and finally server will hand over the response to client.
- Finally container will delete both the request and response object and delete the thread.
So in this tutorial we have seen how servlet container works, and we could see server will not be doing any processing of request if client asks for some dynamic response, instead servers took the help of servlet container and provide the response.
If you like this tutorial, please share this with your friends. If you have any questions or feedback please comment your queries in the comment box.