wood burning stoves 2.0*
The moose likes Servlets and the fly likes Difference between requestDispatcher.forward() and RequestDispatcher.include()? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Difference between requestDispatcher.forward() and RequestDispatcher.include()?" Watch "Difference between requestDispatcher.forward() and RequestDispatcher.include()?" New topic
Author

Difference between requestDispatcher.forward() and RequestDispatcher.include()?

rk
Greenhorn

Joined: Sep 27, 2005
Posts: 5
Pls Give me a brief explain with examplle of this qusetion..
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

"rk",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
[ October 13, 2005: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by rr rk:
Pls Give me a brief explain with examplle of this qusetion..


Please read the docs. There is no other better substitute.

RequestDispatcher API Docs
[ October 14, 2005: Message edited by: Adeel Ansari ]
Ishan Bhatt
Greenhorn

Joined: Oct 09, 2005
Posts: 14
The difference is in their name itself.

forward will forward the request to the new servlet/jsp.
Any out.println() statements in the servlet from where you call the forward method would not be of any use. You can't even call response.getWriter() method in this case. You can only do that in the servlet to which the control has been forwaded.

include will process the included servlet/jsp and any out.println()/html stuff will be included, and then control will come back to the servlet/jsp that called include method.
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
Check out the servlet collections link


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between requestDispatcher.forward() and RequestDispatcher.include()?