从 JSP 请求/会话对象获取服务器 IP 地址 [英] Get Server IP address from JSP Request/session object

查看:18
本文介绍了从 JSP 请求/会话对象获取服务器 IP 地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从 JSP 页面获取服务器的 IP 地址?

How can I get the IP address of the server from a JSP page?

现在,我能做的就是 request.getLocalName(),它返回服务器名称,而不是 IP 地址?

Right now, all I can do is request.getLocalName(), which returns the server name, not the IP address?

推荐答案

其实对于服务器的IP地址,需要使用

Actually, for the IP address of the server, you need to use

String serverIP = request.getLocalAddr();

这篇关于从 JSP 请求/会话对象获取服务器 IP 地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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