Craig McClanahan wrote:
Ah ... there might be a timing issue here, depending on when you ask the
question.
If you ask this question inside an Action.execute() method, the original URI
is available via request.getRequestURI() ... doing a
RequestDispatcher.include() call does not change those path properties.
However, Struts does a RequestDispatcher.forward() at the end of the request
processing lifecycle (i.e. after your Action.execute() method returns). At
that point, the container modifies the path properties in the request to
reflect the page (or tile) that you forwarded to.
Yep, that's what I was figuring -- and I'm asking the question in the JSP.
Now, if you're on a Servlet 2.4 container (Tomcat 5.x, for example), all is
still not lost. There is a corresponding set of request attributes (
javax.servlet.forward.request_uri and friends) that will be set to reflect
the original request, so you can ask this question (for example) from within
a tile's JSP page.
I'm on Tomcat 5.5.x, but unfortunately I'm not seeing that behaviour:
javax.servlet.include.request_uri /pages/projects/Projects.jsp
javax.servlet.include.context_path
javax.servlet.include.servlet_path /pages/projects/Projects.jsp
javax.servlet.forward.request_uri /pages/core/layout.jsp
javax.servlet.forward.context_path
javax.servlet.forward.servlet_path /pages/core/layout.jsp
So I can get the context-relative path of either the Tiles layout or the
current JSP included into the layout, but still not the original
request. FWIW I'm just using a ForwardAction pointing to a Tiles
definition. If I forward directly to the JSP, I get the 'forward'
attributes set to the same values as the 'include' attributes above.
On a pre-2.4 container, this feature won't be available ... but it is
something you could probably program into a custom RequestDispatcher
implementation.
Yep, looks like I'll need to do something along those lines. I always
thought that (as long as you didn't have a redirect along the way) the
original request URL got preserved somewhere, but I guess it makes sense
that forwards have an impact too.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]