I am working on a cruise booking app using struts/tiles that uses multiple internal servlet/jsp forwards to reach the right jsp for display. But, once you reach the final jsp that is used to render the page, the ${pageContext.request.requestURL} call in that jsp returns the path of this jsp.
For example
Original request: /booking/getCruiseDetails
gets forwarded to: /booking/validateCruiseDeteails.jsp
gets forwarded to: /booking/validateUser.jsp
finally gets forwarded to: /booking/showCruiseDetails.jsp
So, in /booking/showCruiseDetails.jsp when I call ${pageContext.request.requestURL} I
get /booking/showCruiseDetails.jsp
How do you get the the original (client made) request url from a jsp that has been reached through multiple forwards. I did find the following posts on stackoverflow that hint at the solution here and here, but they don't address how you would go about finding the original request url after multiple forwards have occurred.
解决方案
On the target JSP use:
request.getAttribute("javax.servlet.forward.request_uri")
To find out what the original URL was.
It doesn't require you to take any extra steps on the forwarding servlet