File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Getting request dispatcher object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Getting request dispatcher object" Watch "Getting request dispatcher object" New topic
Author

Getting request dispatcher object

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
RequestDispatcher rd = request.getRequestDispatcher("result.jsp");
RequestDipatcher rd = getServletContext.getRequestDispatcher("result.jsp");

There are two ways of getting the Request Dispatcher ? Whats the relation between the two ?
Brij Garg
Ranch Hand

Joined: Apr 29, 2008
Posts: 234
There is no relation between this method from two different interfaces. It is just that in case of SetvletContext.getRequestDispature method(url), url must be relative to the root of your web application while this can be or not can be true with ServletRequest.getRequestDispature method(url) method.
James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

Can the request dispatcher obtained from the context point to a different application... i mean to a different application?


SCJP 6
Why to worry about things in which we dont have control, Why to worry about things in which we have control ! !
Brij Garg
Ranch Hand

Joined: Apr 29, 2008
Posts: 234

Can the request dispatcher obtained from the context point to a different application... i mean to a different application?


I dont think so. Because every application has its own context. RequestDispature which is obtained, can forward or include resources within that context only.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Getting request dispatcher object