File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Problem in understanding of Request Dispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem in understanding of Request Dispatcher" Watch "Problem in understanding of Request Dispatcher" New topic
Author

Problem in understanding of Request Dispatcher

Daksh Mital
Greenhorn

Joined: Aug 19, 2007
Posts: 19
HI
Can nebody help me with the output of the following code snippet.

Consider the following code snippets.

In the doGet() of FirstServlet:
PrintWriter out = response.getWriter();
out.println("<html><body>Page 1");
RequestDispatcher rd = request.getRequestDispatcher("NextServlet");
rd.forward(request, response);
out.println("
Page 3</body></html>");

In the doGet() of SecondServlet:
PrintWriter out = response.getWriter();
out.println("
Page 2");

What will be displayed on the browser when a GET request is sent to FirstServlet assuming that the buffer is large enough to hold all the data before sending the data to the client?

Am confused with how the RequestDispatcher forward() mechanism works out.
Does it delegate the request and response object completely or what??
Please help


Daksh
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags.

Why not just run it and see what happens? It'd be substantially quicker than waiting for someone to answer your question.

You might also find some information regarding this on the internet. While your results will vary, when I ran this search several of the top hits were direct answers to your question.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in understanding of Request Dispatcher