Had to grab the absolute URL of a JSP today in order to pass it to the Open Graph Protocol for Facebook. I had to set it up to include any query strings as well, and here’s what I came up with, using a bit of inline Java. Enjoy!

String url = (request.getRequestURL()).toString();
  if (request.getQueryString() != null) {
   url += '?' + request.getQueryString();
  }