aspose file tools*
The moose likes Servlets and the fly likes RequestDispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "RequestDispatcher" Watch "RequestDispatcher" New topic
Author

RequestDispatcher

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
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 ??;
fadi aboona
Ranch Hand

Joined: Apr 25, 2010
Posts: 71
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RequestDispatcher