简体   繁体   English

访问 - 了解用户访问我的应用程序的国家/地区

[英]Access - To know from which country the user is accessing my application

In my web application , I need to give access only to the users who are accessing my application from India. 在我的Web应用程序中,我只需要访问从印度访问我的应用程序的用户。 I need to block the users from accessing my application when they try to access outside India.(ie, I willnot allow them to login and will show an error pop-up) Can anyone please tell if this is possible? 当我们试图访问印度以外的地方时,我需要阻止用户访问我的应用程序。(即,我不允许他们登录并显示错误弹出窗口)任何人都可以告诉我这是否可行?

Add a Filter which checks for requests and 添加一个Filter ,用于检查请求和

String ip = request.getRemoteAddress();

Use hostip service api to check for location 使用hostip service api检查位置

For example 例如

http://api.hostip.info/country.php?ip=74.125.236.206

This will give you country code IN 这将为您提供国家代码IN

If you don't get IN then from Filter 如果你没有从过滤器获得IN

response.sendRedirect("someUrl");
return;

otherwise allow request 否则允许请求

chain.doFilter(request, wrapper);

See 看到

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何知道用户正在使用的应用程序名称? - How to know the application name which the user was using? 有没有一种方法可以从用户访问网站的地方获取国家名称? - Is there a way to get the country name from where user is accessing the web site? 如何知道错误来自我的生产应用程序的哪个活动? - How to know from which activity an error comes from my application in production? 自动检测用户所在的国家 - Automatically Detecting Which Country a User is in 从 Web 应用程序访问 MS Access DB - Accessing MS Access DB from web application 如何知道在Java应用程序中登录的用户是谁? - How know which is the user who is login in java application? 我想知道我的应用程序使用的是哪个 .net CLR 版本 - i want to know which .net CLR version my application is using 访问我的Java应用程序中的.txt文件并将其直接显示给用户 - Accessing .txt file inside my java application and showing it to the user directly 我的数据没有解析到数据库。我的城市和国家名称也没有从用户位置获取。? - My data is not parsing to database.Also my city and country name is not fetching from the user location.? 从Java应用程序访问当前登录的Drupal用户 - Accessing currently logged-in Drupal user from Java application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM