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 ...
随机推荐
- [Android Pro] Android以root起一个process[shell脚本的方法]
reference to : http://***/Article/11768 有时候我们写的app要用uid=0的方式启动一个process,framework层和app层是做不到的,只有通过写脚 ...
- maven配置httpclient3.X jar包
<dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging& ...
- BeatifulSoup文档地址
http://www.crummy.com/software/BeautifulSoup/bs4/doc/index.zh.html
- vector< vector<int> >类似于二维数组
vector< vector<int> > intVV; vector<int> intV; int i,j; ;i<;++i){ intV.clear(); ...
- 三、jQuery--jQuery实践--搜索框制作
input标签讲解 <input/>作为按钮的type属性:button.submit(后面会有二者对比分析)
- Android -- android.os.Parcelable[] cannot be cast to ...
我本想直接把Bunde.getParcelableArray(...)得到的Parcelable[]强制转换为自定义类数组,但是失败了,网上找了两种解决办法: Parcelable[] data =b ...
- grep -i 不区分大小写
# rpm -qa|grep -i "mysql" MySQL-server--.rhel5.x86_64 MySQL-test--.rhel5.x86_64 MySQL-embe ...
- 攻城狮在路上(壹) Hibernate(一)--- 软件环境、参考书目等一览表
1.环境配置: web容器:tomcat6.0 JDK:1.7.0_51 hibernate:4.2.0.Final 操作系统:WIN8 64位 数据库:mysql Ver 14.12 Distri ...
- Oracle【IT实验室】数据库备份与恢复之六:LogMiner
6.1 LogMiner 的用途 Oracle LogMiner 是Oracle公司从产品8i以后提供的一个实际非常有用的分析工具,使用该工具可以轻松获得 Oracle 重作日志文件(归档日志文件) ...
- angularjs 权威指南 版本 1.2.6
1 $rootScope run : run 方法初始化全局的数据 ,只对全局作用域起作用 如$rootScope <script src="http://apps.bdimg.c ...