Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet calling

 
Manish Jaju
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • 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.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic