Usually, to get the request URL in a JSP, I would use
${pageContext.request.requestURL}
but on the project I am working with (because we use tiles I guess) if I run the above I get something like
WEB-INF/pathTo/pageName.jsp
even if the request URL is another and that is just the path of the JSP included using tiles.
How do I get the request URL using JSP EL in this situation?
Tiles has already rewritten/forwarded the request, so by the time your jsp gets the request, it wasn't the original request.
Two things you can do..
in your controller grab the original url and place it as an attribute request.setAttribute("origRequestURL", request.getRequestURL())
and then use ${origRequestURL}
see if this attribute maintained the original before the forward:
<% request.getAttribute("javax.servlet.forward.request_uri"); %>
or ${requestScope['javax.servlet.forward.request_uri']}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With