aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Request Dispatcher." Watch "Request Dispatcher." New topic
Author

Request Dispatcher.

syed askari
Greenhorn

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
Greenhorn

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


<a href="http://www.stockapplets.com" 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 ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Request Dispatcher.