>From: "Basuki, Rendra" <[EMAIL PROTECTED]>
>Reply-To: "A mailing list for discussion about Sun Microsystem's Java
>        Servlet API Technology." <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Servlet Context
>Date: Tue, 8 May 2001 11:51:31 -0700
>
>Anyone knows the difference between
>getServletContext().getRequestDispatcher()
>
>with
>
>request.getRequestDispatcher()
>
>???
>
>Thanks
>Rendra
>[...]



Hi :-) there are several emails about it in TOMCAT-USER List:



...
Using request the URL given can be relative and using the application it has
to be absolute begining with a '/'. Check to see if this may
be the cause of the error.
...


...
The relative paths of URLs from the request are differrent than those of the
application.  I don't immediately recall the exact ifferrences,
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
...



Bo
May.08, 2001

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to