I am calling RequestDispatcher.forward() from my servlets to pass control
along to another servlet and/or JSP page (Model 2 type stuff). This has led
me to a question about the flow of control when using RequestDispatcher:
When RequestDispatcher.forward() is invoked, is it supposed to return
*before* the target resource executes? Or, is forward() supposed to wait
until *after* the target resource has completed executing? Or, could it
happen either way? Is the appropriate behavior spelled out in the specs
somewhere?
Using JRun 2.3.3, I have noticed the following behavior with
RequestDispatcher.forward():
- If I forward() to a "normal" HttpServlet (i.e., NOT a JSP servlet), then
forward() waits until *after* the target servlet has executed before
returning.
- If I forward to a JSP servlet, then forward() returns immediately. After
the original servlet completes all of its processing (backing out through
the stack of doPost() and service()), then the JSP servlet executes.
For my situation, I would like to have RequestDispatcher.forward() always
wait until *after* the target resource has executed before returning. This
would give me the ability to execute some cleanup code after the target
resource has executed. [Yes, I know that the original servlet is not
allowed to send any output either before or after invoking forward(). My
cleanup code has nothing to do with the servlet output.]
Any ideas?
--
Stephen A. Williams
HNC Telecommunications Solutions
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets