JSP通过IP获取用户(客户端)的地理位置信息
<%!
//获取客户端的IP
public String getRemoteIP(HttpServletRequest request) {
if (request.getHeader("x-forwarded-for") == null) {
return request.getRemoteAddr();
}
return request.getHeader("x-forwarded-for");
}%>
<%
String ip = getRemoteIP(request);
URL url = new URL("http://ip.taobao.com/service/getIpInfo.php?ip=" + ip);//使用的IP库是淘宝IP库
HttpURLConnection urlConn = (HttpURLConnection)url.openConnection(); InputStream res = urlConn.getInputStream();
Scanner scanner = new Scanner(res);
String urlContent = "";
while (scanner.hasNextLine()) {
urlContent += (String)scanner.nextLine();
} System.out.println(urlContent);
%>
JSP通过IP获取用户(客户端)的地理位置信息的更多相关文章
- 根据ip获取用户地理位置
各大网站都提供根据ip获取用户地理位置信息,这里以新浪的接口为例子 接口地址为:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js ...
- 百度接口通过ip获取用户所在地
/** * 百度接口 * 通过用户ip获取用户所在地 * @param userIp * @return */ public static String get ...
- 百度地图api根据用户IP获取用户位置(PHP)
1.百度地图开放平台找的你的ak ,链接:http://lbsyun.baidu.com/apiconsole/key 2.获取用户ip地址(外网ip 服务器上可以获取用户外网Ip 本机ip地址只能获 ...
- 设置Cookie,登录记住用户登录信息,获取用户登录过得信息
function setCookie(name,value) { var Days = 30; var exp = new Date(); exp.setTime(exp.getTime() + Da ...
- 怎么使用PHP获取用户客户端真实IP的解决方案呢?
function getIp(){if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIE ...
- PHP获取用户客户端真实IP的解决方案是怎样呢?
function getIp(){if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIE ...
- ip获取所在城市名称等信息接口,及函数
函数: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 ...
- 读取全球ip获取用户地区
这个 首先说明下.ip库是qq纯真ip库 dat文件类型 public static string QQipPath = AppDomain.CurrentDomain.BaseDirectory + ...
- html5获取用户当前的地理位置,即经纬度。
$("document").ready(function(){ getMap(); }); function getMap(){ // 百度地图API功能 var map = ne ...
随机推荐
- LinkIssue: Error 'LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or cor
参考:http://blog.csdn.net/junjiehe/article/details/16888197 使用VisualStudio 编译链接中可能出现如下错误: LINK : fatal ...
- 杨辉三角用java实现
代码如下: public class ErArray { public static void main(String[] args) { //杨辉三角 int[][] num = new int[1 ...
- Swift - 让程序挂起后,能在后台继续运行任务
1,程序的挂起和退出 由于iOS设备资源有限.当用户点击了home键,或者另一个应用程序启动了.那么原先那个程序便进入后台被挂起,不是退出,只是停止执行代码,同时它的内存被锁定.当应用程序恢复时,它会 ...
- Cocoapods的安装报错 - Error installing pods:activesupport requires Ruby version >=2.2.2
1.打开终端 2 移除现有 Ruby 默认源 输入以下指令 $gem sources --remove https://rubygems.org/ 3.使用新的源 输入以下指令 $gem source ...
- 瞧一瞧迷一般的SQLDA
With static SQL, host variables used in embedded SQL statements are known at application compile tim ...
- [LeetCode] Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once. For examp ...
- float 的有效数字为七位是怎么得出来的
以下内容来自CSDN网友xian_wwq的回答(http://bbs.csdn.net/topics/390874239): float: 1bit(符号位) 8bits(指数位) 23bits( ...
- zzy:请求静态资源和请求动态资源, src再次请求服务器资源
[总结可以发起请求的阶段:请求动态资源:通过web.xml匹配action然后,自定义Servlet处理该action1)form表单提交请求的时候,用action设定,该页面发起请求的Servlet ...
- 在Salesforce中创建Web Service供外部系统调用
在Salesforce中可以创建Web Service供外部系统调用,并且可以以SOAP或者REST方式向外提供调用接口,接下来的内容将详细讲述一下用SOAP的方式创建Web Service并且用As ...
- KMP模式匹配算法
KMP模式匹配算法 相信很多人对于这个还有点不了解,或者说是不懂,下面,通过一道题,来解决软考中的这个问题! 正题: aaabaaa,其next函数值为多少? 对于这个问题,我们应该怎么做呢? 1.整 ...