You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Leonard Smith <lr...@gmail.com> on 2009/03/19 16:19:11 UTC

How to get list of IP addresses and ports Tomcat is listening on, in a web-app

To all,

I am writing a webapp which runs under tomcat 6.0.18 and I am new to
java. My webapp is configured to load on startup and in the init
method/function I want to get the list of IP addresses and ports that
can be used to connect to my web-app. I cannot use the
HttpServletRequest or ServletRequest because this assumes a connection
has come in and I want this information before any request can come
in.

Is there a way from my web-app, to get a list of IP addresses and
ports that tomcat is listening on? Other java programmers I know
mentioned using JMX, etc but that assumes I know the JMX port, which
could change.

      java.net.InetAddress inetAddress = java.net.InetAddress.getLocalHost();
seems to get me the IP address, but I have not found a way to get the port.

thanks
Len

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to get list of IP addresses and ports Tomcat is listening on, in a web-app

Posted by André Warnier <aw...@ice-sa.com>.
Leonard Smith wrote:
> To all,
> 
> I am writing a webapp which runs under tomcat 6.0.18 and I am new to
> java. My webapp is configured to load on startup and in the init
> method/function I want to get the list of IP addresses and ports that
> can be used to connect to my web-app. I cannot use the
> HttpServletRequest or ServletRequest because this assumes a connection
> has come in and I want this information before any request can come
> in.
> 
> Is there a way from my web-app, to get a list of IP addresses and
> ports that tomcat is listening on? 

You may want to have a look here, for a starter :
http://java.sun.com/docs/books/tutorial/networking/nifs/index.html



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to get list of IP addresses and ports Tomcat is listening on, in a web-app

Posted by Mikolaj Rydzewski <mi...@ceti.pl>.
Leonard Smith wrote:
> Is there a way from my web-app, to get a list of IP addresses and
> ports that tomcat is listening on? Other java programmers I know
> mentioned using JMX, etc but that assumes I know the JMX port, which
> could change.
>   
You will use JMX  beans in the same JVM, so you do not need any ports to 
connect to remote JVM/JMX.

You can try http://www.ceti.pl/~miki/komputery/jmx/ and see what can be 
done with Catalina bean.

-- 
Mikolaj Rydzewski <mi...@ceti.pl>