Get the server port number from tomcat without a request

前端 未结 12 1560
佛祖请我去吃肉
佛祖请我去吃肉 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:15

    • Get Hold of MBean/JMX Object for Tomcat/Server Instance
    • Get Virtual Server Instance Related Data from there

    Check http://svn-mirror.glassfish.org/glassfish-svn/tags/embedded-gfv3-prelude-b07/web/web-glue/src/main/java/com/sun/enterprise/web/WebContainer.java for reference

    The content of the MBeanServer can then be exposed through various protocols, implemented by protocol connectors[RMI/IIOP], or protocol adapters[SNMP/HTTP]. In this case, use of SNMP adapter will be a better approach so that a SNMP trap can be placed without knowing the exact IP/port of other Application Servers

提交回复
热议问题