• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Forwarding requests between servlets

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I forward a request from one servlet to another using requestdispatcher.forward() then which method is called doGet() or doPost().
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Abhay Katekar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rahul,

Got it now.
The request type is extracted from the request headers.
Now its clear.
 
He's dead Jim. Grab his tricorder. I'll get his wallet and this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic