Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

How to use local IP address on a java.net.URLConnection in Java

0

53 views

Hello,

I want to use different IP addresses, which are available on my server with java.net.URLConnection, but when I try to use

    Proxy proxyObj = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(ipaddress, 80));
    HttpURLConnection con = (HttpURLConnection) url.openConnection(proxyObj);
    ....
    BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()));

I am getting the following exception:

java.io.IOException: Server returned HTTP response code: 400 for URL: http://www.google.com
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
....

Could you please advise me on how I can overcome this?

asked April 28, 2011 12:44 pm CDT
posted via StackOverflow

0 Answers

Be the first to answer this question

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions
Java ssl tomcat
March 11, 2011
Openssl with java
March 24, 2011