Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Query String in Request Dispatcher  RSS feed

 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • 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
 
Mark Howard
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
doPost().
The HTTP method that triggered the original request is preserved.
 
suneel kanth
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!