code: public static String percentEncodeUrl(final String urlStr) {
  		if (Util.empty(urlStr)) {
  			return urlStr;
  		}
  
  		try {
  			// Avoid double encoding
  			String decode = URIUtil.decode(urlStr);
  			URI uri = new URI(decode, false);
  			return uri.getEscapedURIReference();
  		} catch (Exception e) {
  			return urlStr;
  		}
  	}
docs: Percent encode a URL to include in HTML.
  
  @param urlStr the URL to escape
  @return the URL percent encoded