aspose file tools*
The moose likes Distributed Java and the fly likes how to use make HTTP request behind a proxy server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "how to use make HTTP request behind a proxy server" Watch "how to use make HTTP request behind a proxy server" New topic
Author

how to use make HTTP request behind a proxy server

Jack Zhou
Ranch Hand

Joined: Dec 27, 2003
Posts: 93
I was looking for a class like Url and HttpsURLConnection to make a HTTP request via proxy server. No sucess. Can any body give any clue?


Thanks,<br />Jack Zhou<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS,SCEA
tommy k. lee
Greenhorn

Joined: Jun 16, 2004
Posts: 20
In order to work with a proxy, your Java application needs to specify information about the proxy itself as well as specify user information for authentication purposes.

System.getProperties().put( "proxySet", "true" );
System.getProperties().put( "proxyHost", "proxyHost" );
System.getProperties().put( "proxyPort", "85" );

Some proxies require a user to type in a username and password before Internet access is granted. Here's how to perform the authentication:

URLConnection connection = url.openConnection();
String password = "username assword";
String encodedPassword = base64Encode( password );
connection.setRequestProperty( "Proxy-Authorization", encodedPassword );


SCJP,SCJD SCEA, SCWCD, SCBCD<br />OCP DBA 8i / 9i<br />CISSP, PMP, PHR<br />CCNA, CCDA <br /><a href="http://www.certgear.com" target="_blank" rel="nofollow">http://www.certgear.com</a>
Rajesh Kamisetty
Greenhorn

Joined: Aug 17, 2004
Posts: 1
I tried this (proxy authentication with URLConnection). But didn't work. Do we have to give the Domain name along with the user name like( CORP\USER )? I don't know what to do?


thanks,<br />Rajesh K
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to use make HTTP request behind a proxy server