${requestScope['javax.servlet.forward.servlet_path']}
gets me the right string, but not including parameters that might be set in the url.
Example:
http://localhost/path/i/want?param=1
should give me a string /path/i/want?param=1
I have a feeling this should be done easily but can't figure it out.
Thanks in advance!
It's available by ${requestScope['javax.servlet.forward.query_string']}
.
I have been looking for a while too.
<c:set var="req" value="${pageContext.request}" />
<c:set var="baseURL" value="${fn:replace(req.requestURL, req.requestURI, '')}" />
<c:set var="params" value="${requestScope['javax.servlet.forward.query_string']}"/>
<c:set var="requestPath" value="${requestScope['javax.servlet.forward.request_uri']}"/>
<c:set var="pageUrl" value="${ baseURL }${ requestPath }${ not empty params?'?'+=params:'' }"/>
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