I would like to find out the ip address of the client that is visiting my web pages.
Content of JSP page:
<%
out.print( request.getRemoteAddr() + "<br>");
out.print( request.getRemoteHost() );
%>
Output:
0:0:0:0:0:0:0:1
0:0:0:0:0:0:0:1
I would like to find out the ip address of the client that is visiting my web pages.
Content of JSP page:
<%
out.print( request.getRemoteAddr() + "<br>");
out.print( request.getRemoteHost() );
%>
Output:
0:0:0:0:0:0:0:1
0:0:0:0:0:0:0:1
<%
out.print( request.getRemoteAddr() );
out. print( request.getRemoteHost() );
%>
request.getRemoteAddr()
return ip
address of the machine from where you
access the jsp page.request.getRemoteHost()
returns the
name of host from which you are
accessing the jsp page. If you access
it from server itself, it will return
server name.If the client is behind a proxy, the above are not useful as you will get the IP of the proxy they are behind, instead try:
<%
out.print( request.getHeader("x-forwarded-for") );
%>
Your methods are correct. I assume that you are accessing it on localhost and therefore hitting the loopback interface. The numbers that you are seeing are the IPv6 IP addresses of your loopback interface.
Trying hitting it from another machine.