Setting The Proxy?
I am making a broswer type app i want to set the proxy only for this browser I tried to modify global proxy by using this code but it does not work System.getProperties().put('http
Solution 1:
System.getProperties().put("http.proxyUser", "someUserName");
System.getProperties().put("http.proxyPassword", "somePassword");
These dont' work in the JDK, only in the Apache HTTP client.
System.getProperties().put("http.proxySet", "true");
This is an urban myth. It appears in some early Java books but has never done anything in the JDK. It is a relic of the defunct HotJavaBean browser c. 1998.
Solution 2:
You should use it like
Authenticator.setDefault(
new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
returnnew PasswordAuthentication(
authUser, authPassword.toCharArray());
}
}
);
System.setProperty("http.proxyHost", someProxyURl);
System.setProperty("http.proxyPort", someProxyPort);
System.setProperty("http.proxyUser", someProxyUser);
System.setProperty("http.proxyPassword", someProxyPassword);
....
Post a Comment for "Setting The Proxy?"