Does the RequestDispatcher.forward/include method return?
RequestDispatcher defines an object that receives requests from the client and sends them to any resource (such as a servlet, HTML file, or JSP file) on the server. The servlet container creates the RequestDispatcher object, which is used as a wrapper around a server resource located at a particular path or given by a particular name.
Actually the RequestDispatcher.forward() and RequestDispatcher.include() are just method calls to the other JSP/servlet.
The control (flow of program)is indeed returned to the line after this line once it completes. The body of the code after the forward will still be processed and any unhandled exceptions will be thrown to requesting servlet.
The control is absolutely returned. However, there are some restrictions on what you can do afterwards -- in particular, you can no longer write to the response (it is assumed that the forwarded-to servlet took care of that already), so the only prudent thing to do is "return".
Most Recent servlet Faqs
- How to get the client information in a Servlet?
- Can I control Session timeout?
- What is the difference between RequestDispatcher's forward method and HttpServletResponse's sendRedirect method?
- When do I use HttpSessionListener?
- What is the difference between the request attribute and request parameter?
- What is the defferent between getNamedDispatcher() and getRequestDispatcher()?
- How do you communicate in between applets and servlets?
Most Viewed servlet Faqs
- What is the difference between the request attribute and request parameter?(12100)
- When do I use HttpSessionListener?(11630)
- How to use ServletContext.getResourceAsStream(java.lang.String path)?(8249)
- What is the difference between RequestDispatcher's forward method and HttpServletResponse's sendRedirect method?(6880)
- Can I control Session timeout?(5293)
- What is the defferent between getNamedDispatcher() and getRequestDispatcher()?(4916)
- How to get the client information in a Servlet?(4477)