As client sends a request to a server, server receives HTTP request and have to respond in HTTP response.Well the server way of communicating over a network is through HTTP, i.e it understands HTTP.
Now, the question is, we have written a JSP or HTML page to raise a request and Servlet is placed there on server side,having the answer for raised request. Now there would be many servlets as such on the server.
Now who will map our request of that particular servlet and responds back in form of HTTP response.
The answer is : Servlet Container
It acts like a controller.
When container recieves a request for a servlet, through your HTTP GET or HTTP POST method, itcreates a response and request object first.
Then controller searches for the particular servlet requested, as mapped in your web.xml, and creates a thread for the same and assigns those request and response object to it.
Request and Response objects are of HttpServlet class, which your servlet extends.
Container calls the service() method of the servlet.
doGet() or doPost() method generates the dynamic page and attach to it the response object.
When thread completes, the container converts the response object into HTTP response and send it to client.
Followed by deletion of request and response object.
So this is the all story about our servlet CONTAINER.
would you be interested for link exchange with our blog at http://software-wikipedia.blogspot.com/. Mail us at software.wikipedia@gmail.com if interested.
ReplyDelete