• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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!!!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic