How container handles the Servlet request

1. User clicks a link that has a URL of Servlet.

2. Container (Apache Tomcat is one of the example) sees that the request is for servlet , so create two objects :

HttpServletRequest
HttpServletResponse

3. Container finds correct servlet on the basis of URL passed with the help deployment descriptor (web.xml) file. Creates / Allocate thread for that request and pass request and response object to servle thread.

4. Container calls the servlets service() method, on the type of request, service calls doGet() or doPost() methods.

5. Lets assume that service calls the doPost() method. doPost() method generates dynamic page and add the page in response object.

6. Thread completes, container converts the response object into HttpResponse object and destroys the response and request object.

Advertisements

About Sanju
I am Software Programmer. I am working in JAVA/J2EE Technologies.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: