Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RequestDispatcher

 
Apan Raj
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any ony let me know the different ways of getting RequestDispatcher object in a servlet, and how actually they differ.
 
Ramakrishnan thiyagarajan
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Request dispatcher is a interface.actually RequestDispatcher means to dispatch the incoming Http request to some other servlet or jsp page. this is a concept.but u can obtain it two ways.
throug ServletContext,HttpServletResponse.
 
Sri Basavanahally
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi !
Ramakrishna is right. The methods used are:
You use either the getRequestDispatcher(relative path of resource)
or getRequestDispatcher(absolute path of resource)
or getnamedDispatcher(name of the resource)(Check the method name)
-Sri
 
Apan Raj
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per the API, there is no much difference between the methods in ServletContext and ServletRequest ( Ramakrishna, its not HttpServletResponse ), except that
the method in ServletContext accept only relative path where as the other method also accept absolute path.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic