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 Request Dispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Request Dispatcher" Watch "Request Dispatcher" New topic
Author

Request Dispatcher

Amit Mohan Tiwari
Greenhorn

Joined: Aug 21, 2006
Posts: 10
why we use RequesDisptcher getNamedDispatcher(String name)

can anyone give the full description of getNamedDispatcher(String name)
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3697
    
    5

Have you tried the API?

http://java.sun.com/j2ee/sdk_1.2.1/techdocs/api/javax/servlet/ServletContext.html


My Blog: Down Home Country Coding with Scott Selikoff
Anselm Paulinus
Ranch Hand

Joined: Sep 05, 2003
Posts: 389
I googled out this; think it answers your question.

http://java.boot.by/wcd-guide/ch03s05.html
subbarao N.V
Greenhorn

Joined: Aug 21, 2006
Posts: 13
hi

RequestDispatcher rd1=servletContext.getrequestDispatcher("/servleturlpattern");


Here you are passing the url pattern of the servlet.

RequestDispatcher rd1=Request.getNamedDispatcher("servletname");

getNamedDispatcher is the method as part of the Request interface.For this method you are passing the servlet name(this name you are providing as part of the web.xml(<servlet><servletname>servletname</servlet-name></servlet>
Amit Mohan Tiwari
Greenhorn

Joined: Aug 21, 2006
Posts: 10
Hi friends

What I want to know is as follows

1.getNamedDispatcher(String name)

where name is the name of the servlet given in deployment descriptor under <servlet-name> element
and in deployment descriptor under <servlet-class> element we are given the name of the class of the servlet

2.getRequestDispatcher(String path)

where path is the location of the resources(Servlet,jsp,html etc) which we want to dispatch in our current servlet

SO WHAT I WANT TO ASK IS :

IF THE CASE IS THE ABOVE THEN WHY WE HAD THE NEED OF
getNamedDispatcher(String name),because the
getRequestDispatcher(String path)solves our purpose


Thanks
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Amit,

Please be aware that typing with the caps-lock button down is considered yelling in web forums.
You're not going to improve the odds of getting a better answer by yelling at people.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Naresh Waswani
Greenhorn

Joined: Jun 02, 2006
Posts: 5
with getRequestDispatcher(String) method, you can pass the control to any resource be it static or dynamic.And more over the path has to start with "/" as it is taken with refernce to the root context.

but in case of getNamedDispatcher(String), you can pass only to dynamic resource.

regards
Naresh Waswani

9986461501
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Request Dispatcher
 
Similar Threads
getNamedDispatcher ????
is getNamedDispatcher() method out of scope ?
Context root
RequestDispatcher
Request Dispatcher