Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Servlet calling

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When a servlet is called from other servlet using include or forward method of RequestDispatcher, at that time, are doGet or doPost methods (of called servlet) called from calling servlet??? Will someone elaborate this point, I mean explain flow of programm for same above. I will be hightly obliged.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No.

when we do forward(), it means we are passing control to a new web resource, in your case to a servlet. now the new resource, which we have passed the control, is supposed to commit the response.

when we do include(), it means we are passing the control to a new web resource for some processing but the control would be back to the same resource. now the new resource, which we have passed the control, is supposed to process the request or manipulate the response but not commit the response. response would be commited by the same resource that has passed the control to a new resource for some processing only.

and about the method calling. no servlet calls the method doPost() or doGet() of any other resource. container knows which method it should call. because the request object has the method, by which the request is made. we can get that using request.getMethod(). now as we pass the request and response in our forward() and include() method, thus we need not worry.

cheers.
 
Time flies like an arrow. Fruit flies like a banana. Steve flies like a tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic