File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Request Dispatcher.

 
syed askari
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please tell me the purpose of Request Dispatcher.
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friend. A RequestDispatcher object allows you to pass data between servlets. For more info, please visit the Sun servlet tutorial.
 
gigel chiazna
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can include or forward requests
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic