What is the difference between the include() and forward() methods?

What is the difference between the include() and forward() methods?

Ninja Asked on 19th September 2018 in Servlet.
Add Comment
1 Answer(s)
Best answer

The RequestDispatcher include() method inserts the contents of the specified resource directly in the flow of the servlet response, as if it were part of the calling servlet. The include() method is often used to include common “boilerplate” text or template markup that may be included by many servlets.

The RequestDispatcher forward() method is used to show a different resource in place of the servlet that was originally called. The forward() method is often used where a servlet is taking a controller role; processing some input and deciding the outcome by returning a particular response page.

Ninja Answered on 19th September 2018.
Add Comment