This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes Query String in Request Dispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Query String in Request Dispatcher" Watch "Query String in Request Dispatcher" New topic
Author

Query String in Request Dispatcher

Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
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

Joined: Feb 14, 2001
Posts: 285
doPost().
The HTTP method that triggered the original request is preserved.
suneel kanth
Greenhorn

Joined: Feb 06, 2003
Posts: 22
doPost() method of the servletB going to be called.If you keep your code in doGet() corresponding doGet() method of servletB will call.


Any sufficiently advanced bug is indistinguishable from a feature.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Query String in Request Dispatcher
 
Similar Threads
doubt in enthuwere mocktest question
Question ID :995549757220
Thread safe
doGet() and doPost()
omitted extends HttpServlet