This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes what does requestdispatcher forward call Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "what does requestdispatcher forward call" Watch "what does requestdispatcher forward call" New topic
Author

what does requestdispatcher forward call

manish ahuja
Ranch Hand

Joined: Oct 23, 2003
Posts: 312
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

Joined: Sep 23, 2000
Posts: 3285
    
    7
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.


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
manish ahuja
Ranch Hand

Joined: Oct 23, 2003
Posts: 312
Hi Anil
Good Answer.
Rgrds
Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 662
also the request to the target servelet will be delegated to the appropriate doGet/doPost via its own service method.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what does requestdispatcher forward call