jsp A simple way to get local and serverIP
- 2021-11-02 01:58:07
- OfStack
As shown below:
InetAddress addr = InetAddress.getLocalHost();
String ip = addr. getHostAddress (). toString (); //Get native IP
//The ip of the accessed server is: System. out. println ("The accessed ip is:" + ip);
//Visitor's ip is: System. out. println ("ip is:" + request. getRemoteAddr ());