Proxies

F

freesoft_2000

Hi everyone,

If i were to set the http proxy for a particular url i did this

Properties systemProperties = System.getProperties();
systemProperties.setProperty("http.proxyHost", proxy);
systemProperties.setProperty("http.proxyPort", port);

Is the way that i did the best way to do it and am i doing it correctly??

Richard West
 
H

Hemal Pandya

freesoft_2000 said:
Hi everyone,

If i were to set the http proxy for a particular url i did this

Properties systemProperties = System.getProperties();
systemProperties.setProperty("http.proxyHost", proxy);
systemProperties.setProperty("http.proxyPort", port);

Is the way that i did the best way to do it and am i doing it correctly??

Depends on who is going to use the proxy value. If it is some API that
looks for the proxy settings in the system properties then this is the
right way to do it. If the API is not going to look in system
properties then this is useless.
 
E

Esmond Pitt

Hemal said:
Depends on who is going to use the proxy value. If it is some API that
looks for the proxy settings in the system properties then this is the
right way to do it. If the API is not going to look in system
properties then this is useless.

If you don't know the answer please don't just create noise.

As the API concerned is the Java Development Kit, specifically
java.net.HttpURLConnection and the sun.* classes it uses, this way of
doing it is correct.
 
F

freesoft_2000

Hi Everyone,

esmond tahnks for your reply but i have one more question in
that if my proxy requires a username and password i do this

System.setProperty("http.proxyUser","user");
System.setProperty("http.proxyPassword","password");

Is the way that i did the best way to do it and am i doing it correctly??

Another thing i have to ask you is that proxy authentication, is the same
as web page authentication??

Richard West
 
E

Esmond Pitt

freesoft_2000 said:
if my proxy requires a username and password i do this

System.setProperty("http.proxyUser","user");
System.setProperty("http.proxyPassword","password");

I am not aware of these properties. AFAIK you have to use a
java.net.Authenticator.
Another thing i have to ask you is that proxy authentication, is the same
as web page authentication??

Well, there are two values for Authenticator.RequestorType, so there is
a difference.
 
F

freesoft_2000

Hi everyone,

Thanks for answering to my reply Esmond. I read up on the
Authenticator class and now know how to use it but i have one more
question.

Can the Authenticator class also be use to access a password
protected https or ftp site or is the Java Authenticator class only meant
for http internet protocol only.

If it can access more than http have you done it before and
did it work??

I know these may seem like basic questions to you but
please bear with me.

Hoping to hear from you

Yours Sincerely

Richard West
 
E

Esmond Pitt

freesoft_2000 said:
Thanks for answering to my reply Esmond. I read up on the
Authenticator class and now know how to use it but i have one more
question.

Can the Authenticator class also be use to access a password
protected https or ftp site or is the Java Authenticator class only meant
for http internet protocol only.

HTTP or HTTPS, proxy or server.
If it can access more than http have you done it before and
did it work??

Probably at some point, I can't remember for sure.
 
F

freesoft_2000

Hi everyone,

Sorry Esmond but going back to the proxy story in my first
post i did something like that

Properties systemProperties = System.getProperties();
systemProperties.setProperty("ftp.proxyHost", proxy);
systemProperties.setProperty("ftp.proxyPort", port);

but i notice that in one wesite that i have read some people did it like
this

Properties systemProperties = System.getProperties();
systemProperties.setProperty("ftpproxyHost", proxy);
systemProperties.setProperty("ftpproxyPort", port);

Are both versions correct??
If not which is the correct version and which one do you normally use??

Richard West
 
E

Esmond Pitt

freesoft_2000 said:
Hi everyone,

Sorry Esmond but going back to the proxy story in my first
post i did something like that

Properties systemProperties = System.getProperties();
systemProperties.setProperty("ftp.proxyHost", proxy);
systemProperties.setProperty("ftp.proxyPort", port);

but i notice that in one wesite that i have read some people did it like
this

Properties systemProperties = System.getProperties();
systemProperties.setProperty("ftpproxyHost", proxy);
systemProperties.setProperty("ftpproxyPort", port);

Are both versions correct??
If not which is the correct version and which one do you normally use??

There are some old system properties e.g. proxyHost/proxyPort which are
still supported because their existence 'leaked' (from the HotJava
Bean), and there is also proxySet which people are still coding into
applications even though it has made no difference for about seven
years. Use the http.* and ftp.* ones.

EJP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top