Take the 2-minute tour ×  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).  share|improve this question Why is
there a bounty on this question ? This looks random... – 
dystroy Mar 28 '13 at 8:52  7 Answers 7  up vote 138 down vote
accepted  The HttpServletRequest has the following methods:    •
getRequestURL() - returns the part of the full URL before query
string separator character ?   • getQueryString() - returns the
part of the full URL after query string separator character ?
So, to get the full URL, just do:  public static String
getFullURL(HttpServletRequest request) {     StringBuffer
requestURL = request.getRequestURL();     String queryString =
request.getQueryString();      if (queryString == null) {
return requestURL.toString();     } else {         return
requestURL.append('?').appe