File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes What is the difference between Submit and Foward in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "What is the difference between Submit and Foward in jsp" Watch "What is the difference between Submit and Foward in jsp" New topic
Author

What is the difference between Submit and Foward in jsp

Chiran Mathur
Ranch Hand

Joined: Feb 07, 2001
Posts: 63
What are the differences between doing a submit and foward in JSP?
g madhava
Ranch Hand

Joined: Sep 14, 2001
Posts: 85
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".
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
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
Maha Annadurai
Ranch Hand

Joined: Oct 27, 2002
Posts: 87
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

Any insights?
Thanks!
-Maha
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is the difference between Submit and Foward in jsp