This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes RequestDispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "RequestDispatcher" Watch "RequestDispatcher" New topic
Author

RequestDispatcher

Apan Raj
Greenhorn

Joined: Sep 04, 2003
Posts: 20
Can any ony let me know the different ways of getting RequestDispatcher object in a servlet, and how actually they differ.


"If everything is in your way, sure you are on the wrong lane"
Ramakrishnan thiyagarajan
Ranch Hand

Joined: Oct 07, 2003
Posts: 57
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

Joined: Oct 07, 2003
Posts: 75
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


UP THE IRONS !
Apan Raj
Greenhorn

Joined: Sep 04, 2003
Posts: 20
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.
 
subject: RequestDispatcher
 
Similar Threads
sendRedirect
difference between RequestDispatcher from a ServletRequest and from a ServletContex
HTTP Status 500
servlets
How to Jsp in servlet