pls help me with this... I've a doubt in this code..this from a jdiscuss mock exam
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("<br>Page 3</body></html>"); In the doGet() of SecondServlet: PrintWriter out = request.getWriter(); out.println("<br>Page 2");
Yes, control returns to the calling resource like in any method. Only, you can't access the output stream. If you insert <jsp:forward...> in a jsp, then in the translated servlet, the container might insert a 'return' statement immediately after the rd.forward() call.