<%!
// Get client's 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);// The use of IP The library is Taobao IP library
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 adopt IP Get users ( client ) More articles on location information of

  1. according to ip Get user geographic location

    All major websites provide the basis for ip Get user geographic location information , Take Sina's interface as an example The interface address is :http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js ...

  2. Baidu interface through ip Get the location of the user

    /** * Baidu interface      * Through users ip Get the location of the user      * @param userIp      * @return      */ public static String get ...

  3. Baidu Maps api According to the user IP Get the user's location (PHP)

    1. Baidu map open platform to find your ak , link :http://lbsyun.baidu.com/apiconsole/key 2. Get users ip Address ( Extranet ip The server can access the user's Internet Ip This machine ip The address can only get ...

  4. Set up Cookie, Login remember user login information , Get the login information of the user

    function setCookie(name,value) { var Days = 30; var exp = new Date(); exp.setTime(exp.getTime() + Da ...

  5. How do you use it? PHP Get the user client real IP The solution to this problem ?

    function getIp(){if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIE ...

  6. PHP Get the user client real IP What's the solution ?

    function getIp(){if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIE ...

  7. ip Get the city name and other information interface , And functions

    function : 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 ...

  8. Read Global ip Get the user area

    This First of all, let's explain .ip Kuo is qq pure ip library dat file type public static string QQipPath = AppDomain.CurrentDomain.BaseDirectory + ...

  9. html5 Get the user's current geographic location , Longitude and latitude .

    $("document").ready(function(){ getMap(); }); function getMap(){ // Baidu Maps API function var map = ne ...

Random recommendation

  1. PHP-Redis Extended user manual ( One )

    // initialization redis example $redis = new Redis(); /* connect . open link redis * @param string host redis Server address * @para ...

  2. Between sibling elements CSS control

    In order to achieve this navigation effect : Select an item in the menu , Hide your left background line , At the same time, let his next brother element also hide the lines . There's a kind of selector called the sibling element selector , Divided into near brothers and ordinary brothers . Close to brother : use + Express , Match only that element ...

  3. css A preprocessor for sass

    I thought it was about css What? Nothing , Later, I was asked ... And then it's sad ... sass It's a kind of css Preprocessor for , It's a functional css Programming for : Mainly on the official website http://www.w3cplus.com/ ...

  4. winform: Cannot reference other class libraries ,dll,using And so on 【 chart 】

    Related class libraries have been referenced in the project class library , There's no problem building solutions , But to the post code , adopt using When referring to other class libraries , Then generate the solution or generate a single class library , Will report “ Could not find type or namespace “xxx"( Is there a lack of ...

  5. Makefile Use in foreach Generate a class of rules

    CSDN On , A friend posted a question like this ( I translate it according to my own understanding ): There are four static library files in the current directory :  liba.a libb.a libc.a libd.a. Now I want to make them into a dynamic library libp.so. ...

  6. php Match pictures 、 Video file 、 Regular expressions for music files

    $pattern_video = "/(src)=(\\\?)([\"|']?)([^ \"'>]+\.(swf|flv|mp4|rmvb|avi|mpeg|ra| ...

  7. 《Miracle_House》 Team project system design improvement

    One . Team project system design improvement : 1. Analyze the deficiencies of the first draft of project system design specification , In particular, the modeling of software system structure model is not perfect : For the original document , The errors in the design drawings and the inaccuracies in the text description have been modified . 2. Team project Githu ...

  8. Zookeeper —— First time to know

    What is? Zookeeper Zookeeper Is an open source distributed coordination service , Created by Yahoo , yes Google Chubby Open source implementation : Zookeeper It's a typical distributed data consistency solution , Distribution ...

  9. Tx.Origin For authentication

    Solidity There's a global variable in ,tx.origin, It traverses the entire call stack and returns the original send call ( Or transactions ) The address of your account . Using this variable to authenticate in a smart contract makes the contract vulnerable to phishing like attacks . For further reading ...

  10. 10 Learn to write in minutes Jquery plug-in unit

    Recently, many netizens said jquery What is a plug-in ? How to write it ? I can't write ?   I don't know how to answer a lot of questions , I think it's netizens who complicate the problem . In fact, it is to put some commonly used . practical . General functions are packaged with , It's easy to ...