Get Application Server name or ip and port in Java

后端 未结 3 441
粉色の甜心
粉色の甜心 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 01:43

    You can use ServletRequest#getLocalXXX() methods for this.

    • ServletRequest#getLocalName() returns local hostname.
    • ServletRequest#getLocalAddr() returns local IP.
    • ServletRequest#getLocalPort() returns local port.

提交回复
热议问题