Host IP Address 0:0:0:0:0:0:0:1 on Servlet

ip, java, jsp, network-programming, servlets

Solution

If you are using the `localhost` in your request URI, then the IPv6 is `0:0:0:0:0:0:0:1`. Instead of using `localhost`, use your IPv4 in your request URI to get the correct IP.

Problem

I am trying to get the user Host, IP, and Port using: ``` request.getRemoteHost() request.getRemoteAddr() request.getRemotePort() ``` But I am getting: Host: 0:0:0:0:0:0:0:1 IP: Address null Port: 51111 How do I get the correct IP address, noting that our network IP start with 10.100.x.x Many thanks.

Original source