This question shows that when forwarding, the information in the request object is updated to reflect the new file. So for example, when:
user requests "/abc" -> servlet is invoked > forwards to /def.jsp
Then in def.jsp
${request.requestURI}
will be /def.jsp
rather than /abc
. If one wants to obtain the original requested URI (or any other information, like servlet path, etc):
request.getAttribute("javax.servlet.forward.request_uri");
All fine, but how can I access this via JSTL. ${javax开发者_运维百科.servlet.forward.request_uri}
doesn't work. The dot is considered an operator, rather than part of the name. In other cases, this is solved by putting the name in square brackets and quoting it. But here there is no map object, and ${['javax.servlet...']}
does not work.
So, how?
(I can put it in a "dotless" attribute in the servlet, but that's a workaround)
As far as I remember, it's something like this:
${requestScope["javax.servlet.forward.request_uri"]}
精彩评论