Configure proxy server HttpURLConnection

Configure proxy server HttpURLConnection

If you or your company using proxy server to filter out the request then please pass proxy server information as below to send request and get response:

Proxy proxy = new Proxy(Proxy.Type.HTTP, 
            new InetSocketAddress("proxy_server_name",8080));
        URL url = new URL("http://www.google.com/search?"
            + "q=javahonk.com");
        HttpURLConnection httpURLConnection = 
            (HttpURLConnection) url.openConnection(proxy);

Leave a Reply

Your email address will not be published. Required fields are marked *