This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

getNamedDispatcher ????  RSS feed

 
Ranch Hand
Posts: 359
  • 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
 
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.
 
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.
 
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 !!!
 
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
 
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!