I want to programmatically get the servlet containers port that my Java EE application is deployed on. I assumed there would be something in the JMX beans but I can't seem to find anything.
And before anyone says grab the port from the HttpRequest or HttpResponse it should be noted that this process is running behind the servlet and has no interaction with the Requests or Responses.
解决方案
One possible "hack" would be to parse the server.xml at runtime and identify the port that is configured.
But looks like there is a way to do it using JMX / MBeans as well.