C
Christophe Darville
Daniel Hagen said:Christophe said:Sam,
Unfortunately, this is not DNS caching problem. When I ping (on the same
machine where my java application is running) the domain, the new ip address
is exact (after a few seconds, of course) but it is never exact in the java
application. The only way to use the new ip, is to restart the java
application.
So it is a DNS caching problem, but at the java level
Christophe
Just a thought (not considered very carefully, not tested and a very
ugly workaround):
Couldn't you use the API of your underlying OS via JNI to get the IP and
set the HTTP Host Header "manually" for the URLConnection?
Something like:
String formattedIp = someIpFormatMethod(
someNativeGetHostByNameMethod("a.domain") );
URL url = new URL("http://" + formattedIp);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty( "Host", "a.domain");
[...]
Daniel
Hi Daniel,
Your workaround works fine !
The connection.setRequestProperty("Host","...") command was the piece of
puzzle that was missing to me to solve the virtual hosting problem !
Thank you very much
Christophe