This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getNamedDispatcher confusion

 
Prithvi Sehgal
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I am looking forward to know the following aspects related getNamedRequestDispatcher(String)

  • 1. Why request attributes for forwarding and request are not added into getNamedRequestDispatcher()
  • 2. What's the practical use of getNamedRequestDispatcher()


  • Any pointers would be useful.

    BR,
     
    Frits Walraven
    Creator of Enthuware JWS+ V6
    Saloon Keeper
    Pie
    Posts: 2337
    87
    Android Chrome Eclipse IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Prithvi,

    Why request attributes for forwarding and request are not added into getNamedRequestDispatcher()

    The specifications give no explanation "why they should not be set", they only tell that they should not be set. The only logical explanation I can think of is that the getNamedRequestDispatcher() can be used to forward or include to Servlets that are configured in the web.xml without a <servlet-mapping>. It is actually the only way to reach a Servlet or JSP that cannot be reached directly by the client.

    Probably the guys who wrote the specs thought that you would be interested in the request attributes (like "javax.servlet.forward.request_uri") until you have reached the point of using Servlets that are "protected from the outside URLs". If you are still interested in these parameters then you can still add them as an attribute to the request yourself though....

    What's the practical use of getNamedRequestDispatcher()

    Getting to Servlets in your web-application that should not be reached directly from a client

    Regards,
    Frits
     
    Prithvi Sehgal
    Ranch Hand
    Posts: 774
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks Frits for the explanation.

    I am just wondering what is the practical use? Do we use getNamedDispatcher() pretty often?

    BR,
     
    Frits Walraven
    Creator of Enthuware JWS+ V6
    Saloon Keeper
    Pie
    Posts: 2337
    87
    Android Chrome Eclipse IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I am just wondering what is the practical use? Do we use getNamedDispatcher() pretty often?

    I haven't other than during my certification preparation... and nowadays with all the mvc-frameworks around we hardly configure Servlets other than the ControllerServlet in the web.xml. I doubt if those frameworks use the getNamedDispatcher() "under the hood" at all.

    Regards,
    Frits
     
    Prithvi Sehgal
    Ranch Hand
    Posts: 774
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Dear Frits,

    Thanks for your explanation.

    BR,
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic