A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Web Component Certification (SCWCD/OCPJWCD)
Joined: Sep 01, 2005
Oct 26, 2007 21:11:00
In the doGet() of FirstServlet: PrintWriter out = response.getWriter(); out.println("<html><body>Page 1"); RequestDispatcher rd = response.getRequestDispatcher("SecondServlet"); rd.forward(request, response); In the doGet() of SecondServlet: PrintWriter out = response.getWriter(); out.println("<br>Page 2</body></html>");
Consider the following code snippets. 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?
what will be the output of following code
Joined: Jul 31, 2006
Oct 27, 2007 04:01:00
I guess Page 2 will be displayed , the buffer from the first
will be cleared..
tej<br /> <br />SCJP 1.5 --75%<br />SCWCD --89%<br />SCBCD/Web Services!! Yet to Decide
Joined: Mar 27, 2003
Oct 27, 2007 06:15:00
Yes it should be just "<br>Page 2</body></html>" - you might find this other thread useful:
What is allowed after forward()?
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 /
Joined: Apr 20, 2002
Oct 27, 2007 07:16:00
RequestDispatcher rd = response.getRequestDispatcher("SecondServlet");
You cannot get a RequestDispatcher from a response...
I agree. Here's the link:
subject: RequestDispatcher doubt
Problem in understanding of Request Dispatcher
RequestDispatcher to servlet
Question from JWebPlus
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015