Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the forward information in JSTL / EL, being an attribute containing a dot

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)

like image 737
Bozho Avatar asked Dec 06 '22 00:12

Bozho


1 Answers

As far as I remember, it's something like this:

${requestScope["javax.servlet.forward.request_uri"]}
like image 80
axtavt Avatar answered Dec 08 '22 03:12

axtavt