当前位置:网站首页>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;}
边栏推荐
- 【Leetcode】470. Implement Rand10() Using Rand7()
- JSP out.write()方法具有什么功能呢?
- thinkphp漏洞总结
- security CSRF漏洞保护
- 解析正则表达式的底层实现原理
- [Headline] Written test questions - minimum stack
- 如何优雅的消除系统重复代码
- When Netflix's NFTs Forget Web2 Business Security
- Deliver cloud-native microservices applications with Zadig
- OpenCV DNN blogFromImage()详解
猜你喜欢
Detailed explanation of Zadig's self-testing and tuning environment technical solution for developers
Using the "stack" fast computing -- reverse polish expression
GetHashCode与Equals
Excel导入和导出
Win10安装DBeaver连接MySQL8、导入和导出数据库详细教程
一篇永久摆脱Mysql时区错误问题,idea数据库可视化插件配置
An overview of the most useful DeFi tools
Axure tutorial - the new base (small white strongly recommended!!!)
When Netflix's NFTs Forget Web2 Business Security
【21天学习挑战赛】顺序查找和二分查找的小总结
随机推荐
一个有些意思的项目--文件夹对比工具(一)
DVWA靶场环境搭建
在不完全恢复、控制文件被创建或还原后,必须使用 RESETLOGS 打开数据库,解释 RESETLOGS.
asyncawait和promise的区别
SphereEx苗立尧:云原生架构下的Database Mesh研发实践
TCP 可靠吗?为什么?
LeetCode_322_零钱兑换
Artifact XXXwar exploded Artifact is being deployed, please wait...(已解决)
els 方块变形
【Leetcode】473. Matchsticks to Square
电机原理动图合集
Win11如何获得最佳电源效率?
20220725 Information update
回顾历史5次经济衰退时期:这一次可能会有何不同?
学习笔记:机器学习之回归
【Leetcode】470. Implement Rand10() Using Rand7()
不了解SynchronousQueue?那ArrayBlockingQueue和LinkedBlockingQueue不会也不知道吧?
零基础如何学习单片机,一位入门者的进阶路径,可参考
JSP如何使用page指令让JSP文件支持中文编码呢?
JSP如何使用request获取当前访问者的真实IP呢?