• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getNamedDispatcher ????

 
Frank Jacobsen
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know when or why i schould use a getrequestdispatcher, but what is the getNamedDispatcher fore ???

Both takes a string, and return a RequestDispatcher ??

Frank
 
Gaurav Gambhir
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is also one way of getting the RequestDispatcher, instead of giving the path we give the name of servlet.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You give a name to your servlets, in web.xml, in the servlet-name tag. You can then use this name and pass it to getNamedDispatcher.
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey this sounds cool
i too was confused about this

now i got it

hope the spec has more to add on it !!!
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey this sounds cool
i too was confused about this

now i got it

hope the spec has more to add on it !!!
 
Srikanth Raghavan
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I have a doubt.... Let me explain what I understood, please correct me if I am wrong...

getRequestDispatcher("result.jsp") usually gets the request dispatcher for the JSP page we pass as the arguemtn. And getNamedDispatcher(String) gets us the request dispatcher for of the Servlet with that name we passed as the argument.

Does it mean that getRequestDispatcher() must be used to get a dispatcher for JSP and getNamedDispatcher() must be used to get a dispatcher for Servlet???

Sorry if my question is stupid, I am preparing for the exam and I don't have hands-on exp.

Thank you
 
salil verma
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getRequestDispatcher() and getNamedDispatcher() can be used for servlet as well as for jsp file. The only difference is that in case of getRequestDispatcher() we use uri. while in case of getNamedDispatcher() we use value defined in <servlet-name> tag in web.xml file for that particular entry.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic