• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

RequestDispather

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In HF book i saw the example for RequestDispatcher forwarding to JSP.
How do we forward request to Servlet?

Is it something like this?

RequestDispatcher rd = request.getRequestDispatcher("MyServlet");

rd.forward(request, response);

Let me know if this is right??
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When u foward to a jsp,u use RequestDispatcher rd=request.getRequestDispatcher("myWebApp/myJSP.jsp");,so it is the same rule when u foward to a servelt by RequestDispatcher rd=request.getRequestDispatcher("myWebapp/myServlet");

anyone correct me if im wrong
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
RequestDispatcher rd = request.getRequestDispatcher("/MyServlet");

Yeah! what you said is right.But you need to do little change with this.While mentioning out servletalias name you need to give the root directory as "/MyServlet".Also before using Requestdispatcher, be sure that you get the corresponding servletcontext of particular web application(i.e., within the web server where it is used to store servlets).
 
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use RequestDispatcher with servlets too, or any other resource for that matter. The arguement you pass to the getRequestDispatcher method is the path to whatever resource you want to use.
[ April 13, 2005: Message edited by: Paul Bourdeaux ]
 
saiprasad raut
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys for the help!!!
 
It's a tiny ad only because the water is so cold.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic