This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Web Services and the fly likes How to get the client's ip address? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "How to get the client Watch "How to get the client New topic
Author

How to get the client's ip address?

Gustavo Santos
Ranch Hand

Joined: Jan 22, 2009
Posts: 40
Hi guys,

Is there a way to get the host's ip address from my webservice class? I'm using axis2.

Cheers,

-gustavo
Shinelin Samuel
Ranch Hand

Joined: Mar 01, 2010
Posts: 55
I think the below code should help you,

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16483
    
    2

Gustavo Santos wrote:How to get the client's ip address?

Gustavo Santos wrote:Is there a way to get the host's ip address from my webservice class?


Which is the real question? Client's IP address or host's IP address?
Gustavo Santos
Ranch Hand

Joined: Jan 22, 2009
Posts: 40
Paul Clapham wrote:
Gustavo Santos wrote:How to get the client's ip address?

Gustavo Santos wrote:Is there a way to get the host's ip address from my webservice class?


Which is the real question? Client's IP address or host's IP address?


I'm sorry for the confusion. Actually I need to know the client's IP address. I tried Paul's solution but it didn't work well for me, I know that it's because of the HostName I sent as the method's parameter.
Gustavo Santos
Ranch Hand

Joined: Jan 22, 2009
Posts: 40
Just so you guys know I've tried the following and it didn't work:




Gustavo Santos
Ranch Hand

Joined: Jan 22, 2009
Posts: 40
Solved!!!



Thank you guys for the support though.

-gustavo
damir novosel
Greenhorn

Joined: Jan 19, 2011
Posts: 1
does someone know how to get the client's port?
Seems like there is no property "REMOTE_PORT"
thanks
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to get the client's ip address?
 
Similar Threads
How to get IP Address of Client Machine?
getting the actual client IP
can we detect location if GPS is not accesible
How to extract country name from IP Address
Can I get source ip address and destination ip address of udp packet?