Meaningless Drivel is fun!
The moose likes Java in General and the fly likes ip or name of server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "ip or name of server" Watch "ip or name of server" New topic

ip or name of server

siva prakash
Ranch Hand

Joined: Aug 24, 2004
Posts: 80
Hi all,

i am having application that runs in one of many servers ( due to load balancing). i need to find the server ip or its name in which the request is processed. i should not use servletrequest object.

is there any way.

With Regards,
Jean-Sebastien Abella
Ranch Hand

Joined: Jul 29, 2005
Posts: 60
I do not know if there is one more specific to your problem but if you are on windows(I'm sure there would be an equivalent on other platform)
the command "ping -a localhost" will give you the name of the current machine
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
See if NetworkInterface.getNetworkInterfaces() and then anInterface.getInetAddress() does what you need. They might come up with more than one answer
[ September 07, 2005: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: ip or name of server
It's not a secret anymore!