Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

include of RequestDispatcher  RSS feed

 
amarkirt saroay
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When and how is the include method of req dispatcher used?
RequestDispatcher rd=request.getRequestDispatcher("/myJsp.jsp");
rd.include(request,response);

What does this statement do?

and what is the differnec between include() and forward methods?
 
Narendhiran Nagarajan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once the servlet forward the request to another servlet or jsp, then it will not care about the response to the client.

But, when you use include, after processing the request by the second servlet, the response will be send back to the first servlet(which does the include) and then the response will be sent to the client.

See the attachment for more detail...
Filename: fwd_inc.bmp
File size: 494 Kbytes
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!