Get Application Server name or ip and port in Java

后端 未结 3 457
粉色の甜心
粉色の甜心 2020-12-15 01:15

We would like to identify and display the server and port that a Java application is running on that is behind a proxy web server. This means that getServerName() and getSer

3条回答
  •  误落风尘
    2020-12-15 02:00

    The server hostname is part of the request, as it depends on what URL the client used to reach your host. The value you get in this way is defined on the client and does not have to be what you expect.

    If you are interested in the local hostname, you can try:

    String hostname = InetAddress.getLocalHost().getHostName();
    

提交回复
热议问题