I wish to get the server name and the current application's port on server startup. I managed to get the host name and address with:
hostName = InetAddress.getLocalHost().getHostName();
hostAddress = InetAddress.getLocalHost().getHostAddress();
But I can't get the port.
I am aware of ServletRequest getPort()
method, but my application doesn't always runs with a request and sometimes actions are being executed via MQ. Therefor, I can't rely on requests.
I am using spring, if it matters.
Can anyone help me find the port?
Thank you,
Idob