Get the server port number from tomcat without a request

前端 未结 12 1556
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-28 06:32

Is there any Tomcat API or configuration available which can tell an application (probably on startup), what port its running on without a request?

Imagine a scenari

12条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-28 07:25

    These types of servers are designed to be able to listen on (almost) arbitrary ports and to hide these details from the contained applications which normally do not need to know.

    The only way is to read the configuration files yourself and have access to the command line arguments that started the server where the configuration files may have been overridden. You have to know a lot about the system you are running on for this to work. There is no way of doing it portably.

    Even if there were, there are cases in which it simply does not matter like being behind a NAT, certain firewalls, etc.

提交回复
热议问题