This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
Originally posted by sharma anurag: and please send me the code also if it is possible for you.
That's not quite how things work here on the Ranch. You'll get all the help you need to write your own code. What specific questions do you have about dispatching? Are you having problems with some existing code?
1) forward: When you use a forward, you can forward your request to any other resource that is managed by your web container. This means that you can forward your request to any other servlet or a JSP and continue to process the request. All the attributes present in that request is available for you for you to continue processing. And once the request is dispatched, it is committed. You cannot continue processing further.
.... RequestDispatcher view = request.getRequestDispatcher("\Servlet1"); view.forward(request,response); // Don't do anything here. Its committed as you have forwarded to another resource.
2) include: Its like taking the help of another container managed resource to do some processing. You send your request to the other resource, perform the requested operation in another resource and get back to the same resource and continue processing further.
.... RequestDispatcher view = request.getRequestDispatcher("\Servlet1"); view.include(request,response); // you can continue processing the request from here .....
subject: About Forward and Include method in Servlet