how can I retrieve the client IP address?

Asked by marc

Everything is in the summary. Thank you for your help.

Question information

Language:
English Edit question
Status:
Solved
For:
play framework Edit question
Assignee:
No assignee Edit question
Solved by:
Guillaume Bort
Solved:
Last query:
Last reply:
Revision history for this message
Caesar (shcaesar) said :
#1

try the following command on a terminal
"sudo hdclient"

if it doesn't work, append the following content to the file /etc/network/interfaces
#-----------------------
auto eth0
iface eth0 inet dhcp
#------------------------

Moreover, if you use wireless connection, replace the "eth0" with "wlan0"; if you have more than one adaptors and the one you refer to is the second one, then replace "eth0" with "eth1"; consequently, "wlan1" for the second wireless interface.

Revision history for this message
marc (marc-ttux) said :
#2

That was not my question :-) You can simply type ifconfig to retrieve your ip address or ifconfig eth0 to get only the one of the eth0 interface.

My question was how do I retrieve the ip address of the client using my webapp. But I think I figured it out, I just need to test:
InetAddress.getLocalHost();

Revision history for this message
Caesar (shcaesar) said :
#3

Glad to know that! And sorry for my misunderstanding :-)

Revision history for this message
Best Guillaume Bort (guillaume-bort) said :
#4

Hm. InetAddress.getLocalHost() will give you the server IP address.
Have you tried the request.remoteAddress property ?

On Sun, Nov 30, 2008 at 1:47 PM, marc
<email address hidden>wrote:

> Question #53026 on play framework changed:
> https://answers.launchpad.net/play/+question/53026
>
> Status: Answered => Open
>
> marc is still having a problem:
> That was not my question :-) You can simply type ifconfig to retrieve
> your ip address or ifconfig eth0 to get only the one of the eth0
> interface.
>
> My question was how do I retrieve the ip address of the client using my
> webapp. But I think I figured it out, I just need to test:
> InetAddress.getLocalHost();
>
> --
> You received this question notification because you are a member of play
> framework developers, which is an answer contact for play framework.
>

Revision history for this message
marc (marc-ttux) said :
#5

Cheers, didn't know about this one. Is it in the manual?

Revision history for this message
marc (marc-ttux) said :
#6

Thanks Guillaume Bort, that solved my question.

Revision history for this message
Guillaume Bort (guillaume-bort) said :
#7

Hm, we still have a lot of work to do with docs ...
But you can find Javadoc API for the stable-3 release here
http://www.playframework.org/docs/play/mvc/Http.Request.html

On Sun, Nov 30, 2008 at 4:11 PM, marc
<email address hidden>wrote:

> Question #53026 on play framework changed:
> https://answers.launchpad.net/play/+question/53026
>
> Status: Answered => Solved
>
> marc confirmed that the question is solved:
> Cheers, didn't know about this one. Is it in the manual?
>
> --
> You received this question notification because you are a member of play
> framework developers, which is an answer contact for play framework.
>