This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Chiran, Doing a submit is just like a normal HTTP submit to the action attribute of the form tag. The action could be either a servlet or a JSP page and this gets executed. Doing a forward in the JSP page (or else using the RequestDispatcher class),would effectively terminate the processing of the current page,and the control now is with with the forwarded page. Note: Were you sure in asking about the difference of the submit and forward. Usually the question would be the difference between "include" and "forward".
Originally posted by g madhava: [...] Doing a forward in the JSP page [...], would effectively terminate the processing of the current page,and the control now is with with the forwarded page.
Beware -- the keyword here is "effectively". Keep in mind that a forward() is essentially just a glorified Java method call. Yes, control goes to the page you forward to, and it is the responsibility of that page to generate the response. But after that, you will return to the forwarding page. This page cannot write anything to the client anymore as the output stream is closed, but other than that it is executing as normal. Why is this important? Sometimes, pages are coded to produced output after a forward because developers do not realise that a forward actually returns. An IOException is thrown; not only does this clog up the server logs, it can have a performance impact as well. Exceptions are not particularly lightweight. - Peter
Peter, I have noticed one thing with Tomcat. I wanted to check if forwarding to another jsp by using the jsp forward action and by using RequestDispathcer are giving the same results. It turned out that, when I use the 'RequestDispatcher' method, I am able to continue the processing in the first forwarding jsp but not with the other technique of <jsp:forward /> Here is the example