JSP getRemoteAddress问题 [英] Problem with JSP getRemoteAddress

查看:223
本文介绍了JSP getRemoteAddress问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解如何获取客户端的IP地址,即访问我的网页。
JSP页面内容:

I would like to find out how to get IP address of the client, that is visiting my web pages. Content of JSP page:

<% 
out.print( request.getRemoteAddr() + "<br>");
out.print( request.getRemoteHost() ); 
%> 

输出:

0:0:0:0:0:0:0:1
0:0:0:0:0:0:0:1


推荐答案

0:0:0:0:0:0:0:1是IPv6环回地址如 RFC 3513 中所定义。

"0:0:0:0:0:0:0:1" is the IPv6 loopback address as defined in RFC 3513.

您的操作系统和应用程序服务器似乎已配置为使用IPv6,并且您正在从本地计算机访问该页面。

It appears that your OS and application server are configured to use IPv6 and that you are accessing the page from the local machine.

顺便说一句,调用getRemoteAddress()将没有为您提供客户端的IP地址。网络中可能存在您可能收到的地址的中间节点。代理和负载均衡器尤其如此。

By the way, calling getRemoteAddress() will not provide you with the IP address of the client. There could be intermediate nodes in the network whose address you might receive. This is especially true of proxies and load-balancers.

这篇关于JSP getRemoteAddress问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆