Dr. Dobb's Journal June 1998
//URL encode the data to the x-www-form-urlencoded MIME format
String urlEncodedData = URLEncoder.encode(data);
System.out.println("URL Encoded Data: " + urlEncodedData);
//Instance the URL (protocol, host, port)
String protocol = getCodeBase().getProtocol();
int port = getCodeBase().getPort();
String host = getCodeBase().getHost();
URL url = new URL(protocol, host, port, "/servlet/ProxyServlet");
System.out.println("Destination URL: " + url.toString());
//Open the connection
urlConnection = url.openConnection();
//Turn off the caching feature
urlConnection.setUseCaches(false);
//Set the URL to POST instead of GET
urlConnection.setDoOutput(true);