File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Request Dispatcher. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Request Dispatcher." Watch "Request Dispatcher." New topic

Request Dispatcher.

syed askari

Joined: Aug 22, 2002
Posts: 6
Please tell me the purpose of Request Dispatcher.
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Hi friend. A RequestDispatcher object allows you to pass data between servlets. For more info, please visit the Sun servlet tutorial.
gigel chiazna

Joined: Jul 09, 2001
Posts: 17
you can include or forward requests

<a href="" target="_blank" rel="nofollow">Stock Market Java Applets</a>
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Here's a simple sample. I have two servlets. The first generates a random number from 0 to 10, stores it in a request attribute as a Long object and forwards to another servlet using RequestDispatcher. The second servlet retrieves the request attribute and renders it on the client browser.
Please note I used the servlet mappings "/one" and "/two". You can test this with the URL http://localhost:8080/myContext/one on Tomcat4.

[ August 22, 2002: Message edited by: Anthony Villanueva ]
I agree. Here's the link:
subject: Request Dispatcher.
It's not a secret anymore!