question about RequestDispatcher forward
Hi,
I've been using RequestDispatcher.forward in some of my jsp codes.
I always thought that when this is called, the page gets forwarded and the rest of the file will not be excuted any more. But recently I just realised that is not the case.
I have some simple code that does this:
<%
int i = 0;
RequestDispatcher dispatcher = null;
String url = "/somepage.jsp";
if (i == 0) {
dispatcher = getServletContext().getRequestDispatcher(response. encodeURL(url));
dispatcher.forward(request, response);
}
System.out.println("PRINT AFTER FORWARD");
%>
When running this page, it does the forwarding and then itcontinues to excute the rest of the page.
Does anyone have a clear explanation for this?
Thanks
|