I have an HttpServletRequest
object.
How do I get the complete and exact URL that caused this call to arrive at my servlet?
Or at least as accurately as possible, as there are perhaps things that can be regenerated (the order of the parameters, perhaps).
In a Spring project you can use
You can use filter .
donot forget to put
<dispatcher>FORWARD</dispatcher>
in filter mapping in web.xmlUse the following methods on HttpServletRequest object
java.lang.String getRequestURI() -Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
java.lang.StringBuffer getRequestURL() -Reconstructs the URL the client used to make the request.
java.lang.String getQueryString() -Returns the query string that is contained in the request URL after the path.