Mark,

The relative paths of URLs from the request are differrent than those of the
application.  I don't immediately recall the exact differrences, but I believe
a url specified as "foo.jsp" that calls http://server/app/foo.jsp from the
request.getRequestDispatcher(url) would have to be 'app/foo.jsp' from the
application.getRequestDispatcher(url).  Though I haven't tested this, and it
is probably not correct, my point is that the paths are not necessarily the
same in the request context as they are in the application context.  When
either getRequestDispatcher(url) method cannot find the url, it returns null.

This is discussed in the servlet and/or jsp spec.

-Mark Howell
[EMAIL PROTECTED] 

Mark Mynsted wrote:
> 
> Has anybody seen this behavior?
> 
> If I use the following code I get no errors.
> 
> RequestDispatcher dispatcher = request.getRequestDispatcher(url);
> dispatcher.forward(request, response);
> 
> If I use the following code I get a null pointer exception because
> dispatcher is null.
> 
> RequestDispatcher dispatcher = application.getRequestDispatcher(url);
> dispatcher.forward(request, response);
> 
> This does not make sense to me.
> 
> request is the subclass of javax.servlet.ServletRequest for this
> request.  application is the javax.servlet.ServletContext.  I know
> that application is defined because I use it all the time for logging,
> e.g. application.log("This is a log message");
> 
> Both the javax.servlet.ServletRequest and javax.servlet.ServletContext
> have a getRequestDispatcher(String) method.
> 
> Sincerely yours;
> 
> Mark Mynsted
> 
> VHA Management Information Systems Client Services
> [EMAIL PROTECTED]
> (972) 830 - 0592, Internal x1592

Reply via email to