I know RequestHeader
provides the host
property that returns the hostname where application is running... but I need this info in my business code. Is there a way to determine the hostname without a RequestHeader
?
There are only two possible solutions to this problem. The first one you've already mentioned which is a RequestHeader. The second one is placing your hostname in the application.conf file.
You can call InetAddress.getLocalHost().getHostName()
to do a reverse lookup on the local host address.
Keep in mind that using the RequestHeader
may be your only option, if the application is proxied in any way and virtual host support is expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With