What is RequestDispatcher?

A request dispatch does the work on the server side. The browser gets the response in the usual way without knowing what is happening in the serverside. The same request, response object is transferred (no new request,response created as sendRedirect()).

The RequestDispatcher has two methods foreward() and include().

RequestDispatcher rd=request.getRequestDispatcher(“result.jsp”);
Rd.foreward(request,response);
//rd.include(request,response);

foreward(): forewards the request to another page to handle it. The original page content is not visible. It is unidirectional.

Include(): it includes the new page to the original. The original page content is visible along with the new one. This is bidirectional.

No comments:

Post a Comment