code: public static String reconstructURL (HttpServletRequest req)
      {
          StringBuffer buf = req.getRequestURL();
          @SuppressWarnings("unchecked") Map<String, String[]> map = req.getParameterMap();
          if (map.size() > 0) {
              buf.append("?");
              for (Map.Entry<String, String[]> entry : map.entrySet()) {
                  if (buf.charAt(buf.length()-1) != '?') {
                      buf.append("&");
                  }
                  buf.append(entry.getKey()).append("=");
                  String[] values = entry.getValue();
                  if (values.length == 1) {
                      buf.append(values[0]);
                  } else {
                      buf.append("(");
                      for (int ii = 0; ii < values.length; ii++) {
                          if (ii > 0) {
                              buf.append(", ");
                          }
                          buf.append(values[ii]);
                      }
                      buf.append(")");
                  }
              }
          }
          return buf.toString();
      }
docs: Reconstructs the request URL including query parameters. <em>Note:</em>
  the output of this method is purely for logging purposes only, thus POST
  parameters are shown as if they were GET parameters and parameters are
  <em>not</em> URL encoded.