aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Servlet flow Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Servlet flow" Watch "Servlet flow" New topic
Author

Servlet flow

Pankaj Shet
Ranch Hand

Joined: Sep 08, 2006
Posts: 239

Hi,
I am having the doubt regarding the request-response flow.
Suppose i send a request or type www.javaranch.com,
where does the request go?
It goes on the server at the javaranch.com,the server then finds the requested page and returns it to client.Now, the requested page will be an html page?
On the server machine,
how many components are there?
where does the Servlet lie??
where does the Web container lie??
where does the actual form lie??
Servlet contains Java code,web container also is a java code,the GET request is an Html request requested by the user,then how does the servlet helps in sending the response??


I just want to know the complete request-response flow
Can anyone give me the link where the image regarding the above flow?


Thank you.


PANKAJ SHET
B.Sc.(I.T.), S.C.J.P., S.C.W.C.D., PGDAC(CDAC)
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Hi Pankaj,

On the server machine, there is a servlet container, that receives the
request, sees which server resources you are talking about from the URL,
loads the class, instantiates the servlet object, creates ServletConfig
object to pass it to the init() method (called only once, suppose it is
first request), now to process the request creates two objects
HttpServletRequest and HttpServletResponse and passes them to the service
method. Sevlet creates a new thread and new call state for each request is
used. Now service method decides what type of client request is. If it is GET, doGet and if it is POST doPost() method of the servlet is called.

Response is sent back to the client using response client that goes back
through the container. Before the response is sent, the content type of the
response is set using setContentType(...) method that tells the client
browser how to use that content.


Hope this much detail render some concepts.


Thanks,


cmbhatt
Atul Sawant
Ranch Hand

Joined: Jul 06, 2006
Posts: 304
Hi Pankaj,

The locations of servlet, the form and jsps are decided upon with web server you are using. for example, in Tomcat, there servlet class file should be placed inside youwebapplication/WEB-INF/classes...this is different in while using java web server. Tomcat uses declarative form to seek information about the storage of particular page/servlet requested.

If you are referring to Head frist servlets and jsp then the first 2 chapters will tell you the basic flow of a resquest/responses and components involved in client and server.


Mission SCWCD. Mission SCJP Complete: SCJP 1.4 - 91%
Pankaj Shet
Ranch Hand

Joined: Sep 08, 2006
Posts: 239

-thanks for the reply.i read ist chapter and half the second one , I understood the flow,thanks..
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Servlet flow