Craig McClanahan wrote:
On 10/27/05, Laurie Harper <[EMAIL PROTECTED]> wrote:
I feel like I should know the answer to this one but I seem to be
stumped... How do I get the actual request URI (or URL) in a JSP that's
included via Tiles?
Both ${pageContext.request.requestURI} and
${pageContext.request.requestURL} are pointing to the Tiles layout JSP,
whether or not I include an <html:base/> tag in the <head> section in
the layout.
To be exact, what I actually need is the full context-relative request
path -- and I'm using URL prefix mapping, so for example the URL I
browse to would be http://host/bin/some/path and the bit I need is
'/some/path'.
If you're within the context of a RequestDispatcher.include() -- which is
what Tiles is doing under the covers -- the servlet container promises to
create some request attributes for you that contain useful information about
the included URI, rather than the original request URI. In particular, the
attribute named "javax.servlet.include.request_uri" will include what you
are looking for. Other attributes of interest:
* javax.servlet.include.context_path
* javax.servlet.include.servlet_path
* javax.servlet.include.path_info
* javax.servlet.include.query_string
(See section SRV.8.3.1 of the Servlet Spec for more info.)
Thanks for the reference; I'd seen those attributes but wasn't sure if
they were standard or not. Unfortunately, I don't think they solve this
particular problem; request_uri has the context-relative path of the JSP
page included by Tiles, but that doesn't match the original request URL.
I think what's going on there is that Tiles is doing multiple, nested
includes so I'm still at least one too many steps removed from the
original request.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]