Tuesday, 17 September 2013

JSP/EL output current URL

JSP/EL output current URL

I'm awful at Java. I've tried looking for this but it is surprisingly hard
to find an answer to despite how easy I'm sure it is.
My URL is: https://www.example.com/path/to/file.jsp
I just need to print it. That simple. Something like:
<a
href="http://www.foo.com?TARGET=https://www.example.com/path/to/file.jsp">Go</a>
I've tried...
(request.getRequestURL()).toString();
...but it gives http://www.example.com/path/to/file.jsp - i need HTTPS
I've tried...
<c:set var="req" value="${pageContext.request}" />
<c:set var="targetURL"
value="${req.scheme}://${req.serverName}${req.contextPath}" />
...but it gives https://www.example.com/
What's in the address bar is and always will be correct. I just need it to
have the proper protocol and full path.

No comments:

Post a Comment