English 中文(简体)
Find the port of the server the application is running in java
原标题:
  • 时间:2009-12-01 06:56:59
  •  标签:
  • java
  • port

Hi I have an application running in tomcat,as well as Weblogic and Websphere I need to determine which port the application is running and display on the UI Is there any JAVA api to find that

最佳回答

If your application is already accessed through that port, you can easily get it from HttpServletRequest.

问题回答

As mentioned by inkredibl the ServletRequest method getServerPort provides this information:

Returns the port number to which the request was sent. It is the value of the part after ":" in the Host header value, if any, or the server port where the client connection was accepted on.

You can t ask a server from the outside for which ports are used by which application. (Ahh, you cam try, but it shouldn t tell). That s obviously a security feature (you could start a port scan, but I guess, that s not exactly what you want...or?)

So the only way out - the application needs to communicate its port number to outer space, either by a simple web page, where the actual port number is desplayed (human-machine-interface) or a separate webservice with a static port number, where a client can request the actual server properties (machine-machine-interface).

(Note: I assumed, the UI is a client application...)





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签