dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Java
Expertise: Intermediate
Jul 2, 2001

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Setting Proxy in Java Code


The java.net package contains classes that deal with connections across the network. If there is a direct connection to the Internet via a modem, various classes like the HttpConnection or the raw Connection class can be used to get a connection to a server on the net.

This approach fails if you are going through a proxy server. To tell the JVM a proxy is installed, system variables need to be set explicitly set using the System class.

What you have to do is basically set three variables. These are:
 
    proxySet
    proxyPort
    proxyHost

This small piece of code shows how to set a proxy before calling the connecting code:
 
//some previous code

    System.getProperties().put(
Irfan Ahmed
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date