• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet flow

 
Ranch Hand
Posts: 338
Scala Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Pankaj Shet
Ranch Hand
Posts: 338
Scala Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
-thanks for the reply.i read ist chapter and half the second one , I understood the flow,thanks..
 
reply
    Bookmark Topic Watch Topic
  • New Topic