(COPY) Connect via socket through a Proxy You have to set the following properties : proxySet, proxyHost and proxyPort.This can be done when starting the JVM for a JAVA application : java -DproxySet=true -DproxyHost=myProxyServer.come -DproxyPort=80 MyJavaAppOr in your source : import java.util.Properties; ...Properties systemSettings = System.getProperties(); systemSettings.put("proxySet", "true"); systemSettings.put("proxyHost", "myProxyServer.com"); systemSettings.put("proxyPort", "80"); System.setProperties(systemSettings);-------------------------------------------------------------------------------- NOTE: You might need to identify yourself to the proxy server. Use the HTTP property "Proxy-Authorization" with a username:password base64 encoded. Properties systemSettings = System.getProperties(); ... System.setProperties(systemSettings);URL url=new URL("http://someserver/somepage"); URLConnection uc = url.openConnection (); String encoded = new String(Base64.base64Encode(new String("username:password").getBytes())); uc.setRequestProperty("Proxy-Authorization", "Basic " + encoded); uc.connect();NOTE: For a base64 function, see this How-to. -------------------------------------------------------------------------------- In a browser, additionnal settings may be needed. For example with Netscape, you add the following lines in pref.js located in the Netscape user directory. user_pref("security.lower_java_network_security_by_trusting_proxies"), true);-------------------------------------------------------------------------------- With the JVM included with IE, guess what, proxy properties have different names. Properties propSystem = System.getProperties(); // Sun VM propSystem.put("proxySet", "true"); propSystem.put("proxyHost", "myProxyServer.com"); propSystem.put("proxyPort", "80"); // Microsoft VM propSystem.put("firewallSet", "true"); propSystem.put("firewallHost", "myProxyServer.com"); propSystem.put("firewallPort", "80"); propSystem.put("http.proxyHost", "myProxyServer.com"); propSystem.put("http.proxyPort", "80");
Connect via socket through a Proxy
You have to set the following properties :
proxySet, proxyHost and proxyPort.This can be done when starting the JVM for a JAVA application : java -DproxySet=true -DproxyHost=myProxyServer.come -DproxyPort=80 MyJavaAppOr in your source : import java.util.Properties;
...Properties systemSettings = System.getProperties();
systemSettings.put("proxySet", "true");
systemSettings.put("proxyHost", "myProxyServer.com");
systemSettings.put("proxyPort", "80");
System.setProperties(systemSettings);--------------------------------------------------------------------------------
NOTE:
You might need to identify yourself to the proxy server. Use the HTTP property "Proxy-Authorization" with a username:password base64 encoded. Properties systemSettings = System.getProperties();
...
System.setProperties(systemSettings);URL url=new URL("http://someserver/somepage");
URLConnection uc = url.openConnection ();
String encoded = new String(Base64.base64Encode(new String("username:password").getBytes()));
uc.setRequestProperty("Proxy-Authorization", "Basic " + encoded);
uc.connect();NOTE: For a base64 function, see this How-to.
--------------------------------------------------------------------------------
In a browser, additionnal settings may be needed. For example with Netscape, you add the following lines in pref.js located in the Netscape user directory. user_pref("security.lower_java_network_security_by_trusting_proxies"), true);--------------------------------------------------------------------------------
With the JVM included with IE, guess what, proxy properties have different names. Properties propSystem = System.getProperties();
// Sun VM
propSystem.put("proxySet", "true");
propSystem.put("proxyHost", "myProxyServer.com");
propSystem.put("proxyPort", "80"); // Microsoft VM
propSystem.put("firewallSet", "true");
propSystem.put("firewallHost", "myProxyServer.com");
propSystem.put("firewallPort", "80");
propSystem.put("http.proxyHost", "myProxyServer.com");
propSystem.put("http.proxyPort", "80");