当前位置:网站首页>How does JSP use request to get the real IP of the current visitor?
How does JSP use request to get the real IP of the current visitor?
2022-08-02 00:18:00 【qq_25073223】
From:
How does JSP use request to obtain the currentWhat about the real IP of the visitor?
The following describes the method to obtain the real IP of the visitor, as follows:
When using a reverse proxy, we <%=request.getRemoteAddr() %>, it will return 127.0.0.1So how do you get the visitor's IP information?The following will come one by one, as follows:Implementation ideas:Get a visitor's real IP with the help of the following methods
public String getIpAddr(HttpServletRequest request) {String ip = request.getHeader("x-forwarded-for");if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {ip = request.getHeader("Proxy-Client-IP");}if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {ip = request.getHeader("WL-Proxy-Client-IP");}if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {ip = request.getRemoteAddr();}return ip;}
边栏推荐
- DOM 事件及事件委托
- Axure教程-新手入门基础(小白强烈推荐!!!)
- 22. The support vector machine (SVM), gaussian kernel function
- 在linux下MySQL的常用操作命令
- 接地气讲解TCP协议和网络程序设计
- 多御安全浏览器android版更新至1.7,改进加密协议
- 众筹DAO“枯萎”的缩影:曾拍下《沙丘》未出版手稿的Spice DAO解散
- 当奈飞的NFT忘记了Web2的业务安全
- How to get the best power efficiency in Windows 11?
- 【Leetcode】470. Implement Rand10() Using Rand7()
猜你喜欢
随机推荐
【Leetcode】2360. Longest Cycle in a Graph
460. LFU 缓存
零基础如何学习单片机,一位入门者的进阶路径,可参考
els 长条变形
中缀转后缀、前缀表达式快速解决办法
security cross-domain configuration
EasyExcel的简单读取操作
如何重装Win11?一键重装Win11方法
当奈飞的NFT忘记了Web2的业务安全
els 方块变形
IP Core: FIFO
已知中序遍历数组和先序遍历数组,返回后序遗历数组
22. The support vector machine (SVM), gaussian kernel function
基于相关性变量筛选偏最小二乘回归的多维相关时间序列建模方法
基于超参数自动寻优的工控网络入侵检测
SphereEx苗立尧:云原生架构下的Database Mesh研发实践
为什么要使用MQ消息中间件?这几个问题必须拿下
图解LeetCode——1161. 最大层内元素和(难度:中等)
20220725 Information update
【无标题】