• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

RequestDispatcher

 
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are two ways of getting a requestDispatcher :

1. RequestDispatcher view = request.getRequestDispatcher("result.jsp");

Here i can also use RequestDispatcher view = request.getRequestDispatcher("/result.jsp");

2. RequestDispatcher view = getServletContext().getRequestDispatcher("/result.jsp");

Here can i use RequestDispatcher view = getServletContext().getRequestDispatcher("result.jsp") or would it give me an error..saying the location has to start from root ??;
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

you get a RequestDispatcher in two ways from the request or from the context. With the servlet context you MUST include the foward slash because you can't specify a path relative to the current resource (the one that received this request.

Hope this helps.
 
Today you are you, that is turer than true. There is no one alive who is youer than you! - Seuss. Tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic