Quantcast
Channel: Active questions tagged servlets - Stack Overflow
Viewing all articles
Browse latest Browse all 717

Can we response to to the browser by a servlet before forwarding request to another servlet through forward method of RequestDispatcher class?

$
0
0
public class ForwardServlet extends HttpServlet {    @Override    protected void doGet(HttpServletRequest req, HttpServletResponse resp)            throws ServletException, IOException {        req.setAttribute("message","This message appended in ForwardServlet");        resp.setContentType("text/html");        PrintWriter pr = resp.getWriter();        pr.println("I m in ForwardServlet"); //trying to response to the browser. but it is not executing, who block the PrintWriter (pr) object before calling forward method of RequestDispatcher ??        RequestDispatcher rd= req.getRequestDispatcher("Servlet1");          rd.forward(req, resp);        pr.println("Comeback to ForwardServlet from Servlet1"); //will not execute, because of either (1)control will not come back to this point??, or (2) PrintWriter (pr) object is blocked??    }}

To know executing mechanism


Viewing all articles
Browse latest Browse all 717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>