• 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

Query String in Request Dispatcher

 
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,
If I have 2 servlet, Servlet A and Servlet B.
Assume that JSP page sent request to Servlet A using POST method....
Code in servlet A
public class Servlet A extends HttpServlet
{
public void doPost(HttpServletRequest req, HttpServletResponse res)
{
String path= "/ServletB?count=5";
RequestDispatcher rd = req.getRequestDispatcher(path);
rd.include(req, res);
}
}
and code in servlet B
public class ServletB extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res)
{
.... // do something
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
{
.... // do something
}
}
In servlet B, what method will be called by web container when received request from servlet A? doPost() or doGet()... ?
thanks
daniel
 
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
doPost().
The HTTP method that triggered the original request is preserved.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
doPost() method of the servletB going to be called.If you keep your code in doGet() corresponding doGet() method of servletB will call.
 
reply
    Bookmark Topic Watch Topic
  • New Topic