Related to connection of httpclient through proxy to web servers

L

Lucky

Hi,

I am using commons-http.jar to connect to the web server and get the
content. Right now I am facing a problem, in my company we have proxy
server because of which I am not able to connect to the web servers.

Please let me know what are the code changes that are required to make
it happen.

Thank,
Deepak
 
G

Gordon Beaton

I am using commons-http.jar to connect to the web server and get the
content. Right now I am facing a problem, in my company we have
proxy server because of which I am not able to connect to the web
servers.

Please let me know what are the code changes that are required to
make it happen.

Create and configure a HostConfiguration object. Use
HttpClient.setHostConfiguration(), or include the config object when
you invoke HttpClient.executeMethod().

/gordon
 
L

Lucky

Got the answer, following is the code snippet for configuring
HttpClient on Windows:

###############################################
m_client = new HttpClient();
m_client.getHostConfiguration().setProxy("wpad.ca.com",80);
NTCredentials credentials = new NTCredentials(userName, password,
proxyServer, domain);
AuthScope authScope = new AuthScope(proxyServer, portNumber);
m_client.getState().setProxyCredentials(authScope, credentials);
###############################################

Thanks Gordon for the reply.

-Deepak
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top