You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Waseem Azhar <wa...@gmail.com> on 2007/09/18 06:16:13 UTC
how to obtain server ip address
Hi,
How do I obtain the IP address of the machine (where the tomcat tomcat
server in running) ? My web app is deployed on tomcat server and I want to
know the Ip address of the server in my application.
Thanks in advance.
-Azhar
Re: how to obtain server ip address
Posted by Waseem Azhar <wa...@gmail.com>.
Yes I want to obtain IP address programmatically, Thanks for the quick help.
-Azhar
On 9/18/07, Lilianne E. Blaze <li...@tlen.pl> wrote:
>
> Check java.net.NetworkInterface, it lets you enumerate all interfaces
> and addresses / interface. Discard loopback 127.0.0.1 and private
> addresses (see rfc 1918), with any luck there should be one address
> remaining. Of course, that is assuming your machine is directly exposed
> to the internet.
>
> http://java.sun.com/j2se/1.5.0/docs/api/java/net/NetworkInterface.html
> http://www.ietf.org/rfc/rfc1918.txt
>
> Or you could use ServletRequest.getLocalAddr(), it's simpler but
> obviously unavailable until someone actually connects to your server, so
> it's unusable with any kind of eager initialization.
>
> Greetings, Lilianne E. Blaze
>
> Waseem Azhar wrote:
> > Hi,
> >
> > How do I obtain the IP address of the machine (where the tomcat tomcat
> > server in running) ? My web app is deployed on tomcat server and I want
> to
> > know the Ip address of the server in my application.
> >
> > Thanks in advance.
> >
> > -Azhar
> >
> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
Re: how to obtain server ip address
Posted by "Lilianne E. Blaze" <li...@tlen.pl>.
Check java.net.NetworkInterface, it lets you enumerate all interfaces
and addresses / interface. Discard loopback 127.0.0.1 and private
addresses (see rfc 1918), with any luck there should be one address
remaining. Of course, that is assuming your machine is directly exposed
to the internet.
http://java.sun.com/j2se/1.5.0/docs/api/java/net/NetworkInterface.html
http://www.ietf.org/rfc/rfc1918.txt
Or you could use ServletRequest.getLocalAddr(), it's simpler but
obviously unavailable until someone actually connects to your server, so
it's unusable with any kind of eager initialization.
Greetings, Lilianne E. Blaze
Waseem Azhar wrote:
> Hi,
>
> How do I obtain the IP address of the machine (where the tomcat tomcat
> server in running) ? My web app is deployed on tomcat server and I want to
> know the Ip address of the server in my application.
>
> Thanks in advance.
>
> -Azhar
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: how to obtain server ip address
Posted by Waseem Azhar <wa...@gmail.com>.
Yes I have tried InetAddress.getLocalHost() and its working ...
Thanks,
-Azhar
On 9/18/07, Sonal Goyal <so...@gmail.com> wrote:
>
> Waseem,
>
> Have you tried InetAddress.getLocalHost()?
>
> Sonal
>
> On 9/18/07, Waseem Azhar <wa...@gmail.com> wrote:
> >
> > Hi,
> >
> > How do I obtain the IP address of the machine (where the tomcat tomcat
> > server in running) ? My web app is deployed on tomcat server and I want
> to
> > know the Ip address of the server in my application.
> >
> > Thanks in advance.
> >
> > -Azhar
> >
>
>
>
> --
> Thanks and Regards,
> Sonal
>
Re: how to obtain server ip address
Posted by Sonal Goyal <so...@gmail.com>.
Waseem,
Have you tried InetAddress.getLocalHost()?
Sonal
On 9/18/07, Waseem Azhar <wa...@gmail.com> wrote:
>
> Hi,
>
> How do I obtain the IP address of the machine (where the tomcat tomcat
> server in running) ? My web app is deployed on tomcat server and I want to
> know the Ip address of the server in my application.
>
> Thanks in advance.
>
> -Azhar
>
--
Thanks and Regards,
Sonal
RE: how to obtain server ip address
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Waseem Azhar [mailto:waseemzhr@gmail.com]
> Subject: how to obtain server ip address
>
> How do I obtain the IP address of the machine (where the
> tomcat tomcat server in running) ?
If you mean you want to obtain the IP address programmatically, you
should read the Servlet API Javadoc (hint: ServletRequest.getLocalAddr).
Otherwise, you'll need to be more specific about what you're trying to
do.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org