• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

getNameDispatcher()

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is getNameDispatcher() ?
And how is it different from getRequestDispatcher() ?
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

public RequestDispatcher getNamedDispatcher(java.lang.String name)



Takes in a String as an argument which should be a valid servlet name mentioned in the DD. Returns a RequestDipatcher which is similar to the one returned by getRequestDispatcher. This finds its use when you define a <servlet> tag with just a name and class and without a <servlet-mapping>.

Hope this helps.

Cheers
Chandu
 
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi !

A RequestDispatcher can be obtained in three ways :
  • from the request, with getRequestDispatcher, giving a relative or an absolute path as a parameter
  • from the context, with getRequestDispatcher, giving an absolute path as a parameter
  • from the context, with getNamedDispatcher, giving a servlet name as a parameter


  • The servlet name given as a parameter to getNamedDispatcher is the name defined in the deployment descriptor :



    One BIG difference (except from the parameter) between a getRequestDispatcher obtained RD and a getNamedDispatcher obtained RD is the implicit parameters.

    When you get a RequestDispatcher (RD) from a getRequestDispatcher() method, either from the request or from the context, and you call forward() or include() method, the RD creates some implicit parameters in the request object passed as a parameter, to give informations about the original request. Informations are :


    Or the same with include instead of forward if you call the include() method.

    Well the big difference is the RequestDispatcher you obtain vi the getNamedDispatcher() method does NOT create these implicit parameters.

    Hope it helps you.

    EDIT : you can find infos about this (and others) in the servlet spec summary i wrote (SRV.8 for RequestDispatcher). See Servlet Spec Summary link in my sig.
    [ March 16, 2006: Message edited by: Frederic Esnault ]
     
    Chandra Sagi
    Ranch Hand
    Posts: 162
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thats a good explaination.

    Thanks
    Chandu
     
    Would anybody like some fudge? I made it an hour ago. And it goes well with a tiny ad ...
    We need your help - Coderanch server fundraiser
    https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
    reply
      Bookmark Topic Watch Topic
    • New Topic