code: public static String optimizeRealPath(PageContext pc, String realPath) {
  	int index;
  	String requestURI = realPath, queryString = null;
  	if ((index = realPath.indexOf('?')) != -1) {
  	    requestURI = realPath.substring(0, index);
  	    queryString = realPath.substring(index + 1);
  	}
  	PageSource ps = PageSourceImpl.best(((PageContextImpl) pc).getRelativePageSources(requestURI));
  	requestURI = ps.getRealpathWithVirtual();
  	if (queryString != null) return requestURI + "?" + queryString;
  	return requestURI;
      }
docs: /*
  public static URL toURL(HttpMethod httpMethod) { HostConfiguration config =
  httpMethod.getHostConfiguration();
  
  try { String qs = httpMethod.getQueryString(); if(StringUtil.isEmpty(qs)) return new
  URL(config.getProtocol().getScheme(),config.getHost(),config.getPort(),httpMethod.getPath());
  return new
  URL(config.getProtocol().getScheme(),config.getHost(),config.getPort(),httpMethod.getPath()+"?"+
  qs); } catch (MalformedURLException e) { return null; } }