简体   繁体   中英

Get Client IP Address in gwt

How to get clients IP address in gwt I tried using this

String ip = InetAddress.getLocalHost()+"";

when i run on local i get proper IP address of my machine but when i deployed it on server i got 127.0.0.1 which is ip address of my development mode link so how can i get client machine's IP address from server.

i also tried using

String ip = getThreadLocalRequest().getRemoteAddr();

it showed the ip address of server but not clients machine ...

Any help ....thanks in advance

My understanding, GWT is not able to get client IP address, because it is compiled into JS, which has no ability to do that. However there is some ways to get IP in the client side, such as applet and flash. and then they could handle the IP address into JS. GWT could make use of JSNI to work with, like applet to get the IP.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM