Hostname detection in java

Is it possible to determine the host name used in java (even via cname)?

I am looking for something similar to this: http://api.drupal.org/api/function/conf_path/6

In this code, drupal checks which domain name is accessing it to load the correct configuration (multisite). If the domain does not match any configurations, it simply goes to the default configuration.

+3
source share
2 answers

Take a look at InetAddress.getLocalHost () , after which getHostName () is called in the return value, which does just that.

, , , . , , , , .

+4

, DNS getHostName().
.
getHostAddress(), .

+1

Source: https://habr.com/ru/post/1750855/


All Articles