code: public String encodeURL(String relativePath, String scheme) {
  		StringBuffer urlEncoded = new StringBuffer();
  		//Context
  		Context context = (Context)sipManager.getContainer();
  		//Host
  		Host host = (Host)context.getParent();
  		//Service
  		Service service = ((Engine)host.getParent()).getService();
  		String[] aliases = host.findAliases();
  		String hostname = null;
  		
  		// Needed for http://code.google.com/p/sipservlets/issues/detail?id=150
  		// to pass TCK test com.bea.sipservlet.tck.agents.api.javax_servlet_sip.ConvergedHttpSessionTest.testEncodeURL002
  		if(aliases.length < 1) {
  			hostname = host.getName();
  		} else {
  			// FIXME would be better to try to match the alias by some path or IP but unaware if this is really needed at this point
  			// or how it can be effectively done
  			hostname = aliases[0];
  		}
  		
  		//retrieving the port corresponding to the specified scheme
  		//TODO ask EG what if the scheme is not supported on the server ?
  		int port = -1;		
  		Connector[] connectors = service.findConnectors();
  		int i = 0;
  		while (i < connectors.length && port < 0) {
  			if(scheme != null && connectors[i].getProtocol().toLowerCase().contains(scheme.toLowerCase())) {
  				port = connectors[i].getPort();
  			}
  			i++;
  		}
  		urlEncoded = urlEncoded.append(scheme);
  		urlEncoded = urlEncoded.append("://");
  		urlEncoded = urlEncoded.append(hostname);
  		urlEncoded = urlEncoded.append(":");
  		urlEncoded = urlEncoded.append(port);
  		urlEncoded = urlEncoded.append(((Context)sipManager.getContainer()).getPath());
  		urlEncoded = urlEncoded.append(encodeURL(relativePath));
  		return urlEncoded.toString();
  	}
docs: /*
  (non-Javadoc)
  @see javax.servlet.sip.ConvergedHttpSession#encodeURL(java.lang.String, java.lang.String)