Tiles and ${pageContext.request.requestURL}
Asked Answered
R

1

7

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?

Rosenthal answered 26/11, 2012 at 13:8 Comment(0)
P
4

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..

  1. in your controller grab the original url and place it as an attribute request.setAttribute("origRequestURL", request.getRequestURL()) and then use ${origRequestURL}

  2. see if this attribute maintained the original before the forward: <% request.getAttribute("javax.servlet.forward.request_uri"); %> or ${requestScope['javax.servlet.forward.request_uri']}

Primogeniture answered 10/1, 2013 at 9:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.