Hello,

>As was pointed out to me, the JSP Spec says that getRequestURI should return the 
>include files
> name, not the original.

I would definitely double-check on that one. I think Tomcat and JRuns
behavior makes more sense both in terms of reason and specs. The
following is a bit lengthy, but I HATE server-specific code :-). Here is
an excerpt from the JSP spec:

<quote>
2.13.6 <jsp:param>
When doing jsp:include or jsp:forward, the included page or forwarded
page will
see the original request object, with the original parameters augmented
with the new
parameters, with new values taking precedence over existing values when
applicable. The
scope of the new parameters is the jsp:include or jsp:forward call; i.e.
in the case of an
jsp:include the new parameters (and values) will not apply after the
include. This is the
same behavior as in the ServletRequest include and forward methods (see
Section
8.1.1 in the Servlet 2.2 specification).
</quote>

And here from the Servlet 2.2 spec:
<quote>
8.3.1 Included Request Parameters
When a servlet is being used from within an include, it is sometimes
necessary for that servlet to
know the path by which it was invoked and not the original request
paths. The following request
attributes are set:
javax.servlet.include.request_uri
javax.servlet.include.context_path
javax.servlet.include.servlet_path
javax.servlet.include.path_info
javax.servlet.include.query_string
These attributes are accessible from the included servlet via the
getAttribute method on the
request object.
If the included servlet was obtained by using a NamedDispatcher, these
attributes are not set.
</quote>

To my understanding, the latter qote shows that the servlet-specific
path should be made available to the included servlet via request
attributes, but the request itself should remain untouched. I wonder
what Orion puts into the request attributes...

This is from the API doc for RequestDispatcher.forward():
<quote>
For a RequestDispatcher obtained via getRequestDispatcher(), the
ServletRequest object has its path elements and parameters adjusted to
match the path of the target resource. 
</quote>

This is from the API doc for RequestDispatcher.include():
<quote>
The ServletResponse object has its path elements and parameters remain
unchanged from the caller's. The included servlet cannot change the
response status code or set headers; any attempt to make a change is
ignored. 
</quote>

I think the latter quote erroneously mentions ServletResponse, but also
means ServletRequest, because Response has no path elements.

"Martin J. Wells" schrieb:
> 
> >
> > Question about request.getRequestURI();
> >
> > In JRun and Tomcat the following applies but not in Orion:
> >
> > I have a JSP (main.jsp) with the tag <jsp:include
> > page="includes/header.jsp"
> > flush="true"/>.  The header.jsp file calls the method
> > request.getRequestURI();
> >
> > The return value in both Jrun and Tomcat are http://site/main.jsp, however
> > in Orion the return value is http://site/header.jsp
> >
> > Is this a bug?  Who's right?
> >
> 
> This one bit me too when we moved over from Tomcat. As was pointed out to
> me, the JSP Spec says that getRequestURI should return the include files
> name, not the original.
> 
> Marty

Reply via email to