Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tiles and ${pageContext.request.requestURL}

Tags:

jsp

el

tiles

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?

like image 270
gotch4 Avatar asked Nov 26 '12 13:11

gotch4


1 Answers

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']}

like image 176
majorbanzai Avatar answered Oct 19 '22 13:10

majorbanzai