views:

141

answers:

1

I get the Yahoo IP address using InetAddress class in java. The result of yahoo.com IP address is not working while given in URL of web browsers.

        InetAddress[] all =   InetAddress.getAllByName("www.yahoo.com");
        for (int i=0; i<all.length; i++)
        {
            System.out.println("  address = " + all[i]);
        }

It shows result as, address = www.yahoo.com/67.195.160.76 address = www.yahoo.com/69.147.125.65

When i entered those ip into browser's url(ie., http://67.195.160.76), the browser shows "Requisted URL not found".

What's the problem in that. Is the result produced by the java program wrong?

+2  A: 

The IP address is not wrong. However, the web server is told exactly what you type into the URL bar, and it can choose to show you different content based on the hostname that you use. In this case, a Yahoo web server (which is at that address) is choosing not to show you anything when you request the host 67.195.160.76.

This information is passed in the Host HTTP header. This header is the basis of how virtual hosts, or "vhosts", work.

Greg Hewgill