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

查看:328
本文介绍了从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天全站免登陆