• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Request Dispatcher

 
Amit Mohan Tiwari
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why we use RequesDisptcher getNamedDispatcher(String name)

can anyone give the full description of getNamedDispatcher(String name)
 
Scott Selikoff
author
Saloon Keeper
Posts: 4015
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried the API?

http://java.sun.com/j2ee/sdk_1.2.1/techdocs/api/javax/servlet/ServletContext.html
 
Anselm Paulinus
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I googled out this; think it answers your question.

http://java.boot.by/wcd-guide/ch03s05.html
 
subbarao N.V
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Naresh Waswani
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic