This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Forwarding requests between servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Forwarding requests between servlets" Watch "Forwarding requests between servlets" New topic
Author

Forwarding requests between servlets

Abhay Katekar
Greenhorn

Joined: Jan 12, 2006
Posts: 11
If I forward a request from one servlet to another using requestdispatcher.forward() then which method is called doGet() or doPost().
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Originally posted by Abhay Katekar:
If I forward a request from one servlet to another using requestdispatcher.forward() then which method is called doGet() or doPost().


RequestDispatcher.forwards() is use to request from a servlet to another resource (servlet, JSP file, or HTML file). and after move this resource Servlet & JSP life cycle is start... mean Servlet call its init method and Jsp call its jspInit method and then call others Method like doGet() or doPost which is defined in that pages.

Correct me if there is something wrong.
Thanks


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by Abhay Katekar:
If I forward a request from one servlet to another using requestdispatcher.forward() then which method is called doGet() or doPost().




Now request goes to the someServlet's service method.The service method determines the command (GET,POST,etc)from the request and delegate the call to the doXXX method in SomeServlet.


Rahul Bhattacharjee
LinkedIn - Blog
Abhay Katekar
Greenhorn

Joined: Jan 12, 2006
Posts: 11
Thanks Rahul,

Got it now.
The request type is extracted from the request headers.
Now its clear.
 
wood burning stoves
 
subject: Forwarding requests between servlets
 
Similar Threads
Scope of implicit response object
Attributes sent from JSP wont show in Servlet
Request dispatcher and send redirect
response.setHeader not working
Servlet virtual path