Get Server IP address from JSP Request/session object

后端 未结 5 673
悲哀的现实
悲哀的现实 2020-12-18 03:15

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

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

5条回答
  •  悲&欢浪女
    2020-12-18 04:18

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

    String serverIP = request.getLocalAddr();
    

提交回复
热议问题