Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the diff between a RequestDispatcher object obtained from Request & Context

 
Ameya Thakur
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between a RequestDispatcher object obtained from the Request object and the RequestDispatcher object obtained from the ServletContext ?
 
Shankar Narayana
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no difference , basically the Request object uses the ServletContexts getRequestDispatcher method.
 
Ameya Thakur
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply as i am not very much sure of the following

1.) request.getRequestDispatcher("url").forward(request,response);

2). getServletConfig().getServletContext().getRequestDispatcher("url").forward(request,response);

One : you can pass relative URL address when using request.getRequestdispather, and absolute URL address when using ServletConfig.getRequestDispatcher.
Two: All request details are not passed when using ServletConfig.getRequestDispatcher. May be it is the query string parameters for the current page that does not reach the page where request is forwarded.

Not very sure of the same

Regards
Ameya
 
Shankar Narayana
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If you can give a thorough look at the servlet API, your doubts will cleared.

Regards,
Shankar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic