Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what does requestdispatcher forward call

 
manish ahuja
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
When using a dispatcher and calling .forward(), will doGet() or doPost() be called in the target servlet?

Rgrds
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3711
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good question The answer depends on what kind of request your are forwarding - GET or POST. If you are forwarding a GET request then doGet will be called, if you are forwarding a POST request then doPOST will be called. Remember that it has nothing to do with the method (doGet or doPost) of the calling servlet. As you are probably aware, many people call doPost from doGet and do all the stuff in doPost (to avoid coding the same thing in both the methods). So if you are forwarding a GET request (from doPost), the other servlet will still get a GET request (not a POST).
HTH,
Paul.
 
manish ahuja
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anil
Good Answer.
Rgrds
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also the request to the target servelet will be delegated to the appropriate doGet/doPost via its own service method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic