Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

what is the difference between<jsp:include> & <jsp:forward>

  Asked By: Tracey    Date: Feb 08    Category: Java    Views: 12700
  

what is the difference between<jsp:include> & <jsp:forward>

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Tyrone Sanchez     Answered On: Feb 08

The difference  between the two tags is that they way they work. Well, I will
say an example so you can imagine it better.

Assume you have two pages, pageA, and pageB. In pageA you wrote the include tag.
In this case the control was in pageA til you called the include tag. At this
point the full control goes to pageB. When It's done, control is returned to
pageA starting from the next point of coding after the include tag and
continuing to the rest of pageA.

Well, to get things much clearer, let's say that we have the same pages, pageA
and pageB, but this time we will use the forward tag in pageA, not the include
tag. Again, the control will begin in pageA till we call the forward tag in
pageA, at this point, control is transfered to pageB, just like the include tag.
But the difference is what happens when pageB completes. In case of the forward
tag, control doesn't go back to pageA again.

 
Answer #2    Answered By: Jonathan Brown     Answered On: Feb 08

Both the <jsp:include> and <jsp:forward> transfer control to new jsp page. The
<jsp:include> action transfers control to a new page, whose results are inserted
into the current page at this point, then execution of the current page
continues. Means control returns back to main page frm where ur including that
page. Opposite to this <jsp:forward> works, giving up the control to the
forwarded page. Control doen't return to main page once u forward it.
This is the only difference  I found. Hope this would help...

 




Tagged: