This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Servlets and the fly likes RequestDispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "RequestDispatcher" Watch "RequestDispatcher" New topic
Author

RequestDispatcher

Cameron Park
Ranch Hand

Joined: Apr 06, 2001
Posts: 371
I am not clear about the two methods from RequestDispatcher. Does forward() ever return from within the servlet's service mthod that called it? If so, then
protected void doGet(HttpServletRequest req, HttpServletREsponse res) throws IOException, ServletException{
RequestDispatcher rd = getServletContext().getRequestDispatcher("response");
rd.forward(req, res);
getPrintWriter("Do you see me??");
}
and
protected void doGet(HttpServletRequest req, HttpServletREsponse res) throws IOException, ServletException{
RequestDispatcher rd = getServletContext().getRequestDispatcher("response");
rd.include(req, res);
getPrintWriter("Do you see me??");
}
How do they differ functionally?
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
'forward' and 'include' primarily vary in what they do with the context, headers and so on. You will see more of an effect in the code you are calling than in the code which calls it.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Poornima Shetty
Greenhorn

Joined: Dec 12, 2000
Posts: 26
basically forward just takes the pain of forwarding the request and response objects to the required jsp,but in include the servlet invokes the objects and substitites their corresponding values and then sends the result to the jsp ,in addition to which it also does some cleaning up of any resources thats no more required.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: RequestDispatcher
 
It's not a secret anymore!