ip of the client machine
hi,
I'd like to write a servlet that would find out the ip address of the machine where it is being run.
can the same program find out the ip address of the client machine if it is hosted on the internet
please help.
Web Development
hi,
I'd like to write a servlet that would find out the ip address of the machine where it is being run.
can the same program find out the ip address of the client machine if it is hosted on the internet
please help.
by jay eckles
See ServletRequest.getRemoteAddr() in the J2EE API specs. You can use it like this:
//(assuming HttpServletRequest request is defined)
String clientIP = request.getRemoteAddr() ;
Good luck.
Jay Eckles
by emkay_mm
by techrep
Hi. You might want to try the code below. It seems to detect internet ip if my machine is connected directly to the internet.
InetAddress localHost = InetAddress.getLocalHost();
String userhost = localHost.getHostAddress();
by emkay_mm
by emkay_mm
This discussion is closed to new replies.
Sort by Trending