How to get the country name from IP address?

Hello All,
I am able get the IP address of the visitors by using
String ipAddress = request.getRemoteAddr(); .
I'm also getting the host name by using
InetAddress iaddress = InetAddress.getByName( ipAddress );
          String ipaddr = iaddress.getHostName();
But... I'm not able to find the Country's name from which that IP is coming from.
Is there any class in JAVA that will help me find the respective country's name??
Thank u!!!

There is no magic way to tell country from IP address. You can guesstimate the country using a IP-to-country mapping database, with some accuracy.
I use the free version of the GeoIP (google for it) database; it is a file that you download, and they have a Java API or you can roll your own. They also have better quality databases for a fee, and apparently a web service. I prefer a file because it's faster and more reliable to check against a memory data structure than to make a long distance TCP/IP call. The web service isn't magic either; it is just an interface to the same database, and it doesn't give 100% accuracy, nothing will. If you use the file you may want to make it a monthly to-do item to download the latest version. There are other similar databases around too; google for "geolocation".

Similar Messages

  • How to get the Country name from where the user access the website ?????

              Hi ,
              i have a requiremtn in which i want to display the country name from where
              the user browse our webpages . for example if he is browsing from us , then i
              should display US and if he is browsing from UK , then i should dispaly "uk" etc...
              can anyone guide me how to proceed .
              thanks in advance
              Regards
              Subu
              

              Hi Laura Taylor ,
              Thanks for your Reply and Thanks for ur Guidelines.
              Thanks & Regards
              Subu.
              "Laura Taylor" <[email protected]> wrote:
              >
              >Unfortunately, there is no way to determine the country unless the client
              >indicates
              >that to you directly(i.e. via a form input value). However, there are
              >two request
              >headers that can help you determine the language preference(s) of the
              >client:
              >
              >Accept-Language -- Specifies the language preference(s) the client prefers
              >to
              >receive.
              >Accept-Charset -- Identifies the charset(s) the client understands.
              >
              >Laura
              >Developer Relations Engineer
              >BEA Support
              >
              >
              >"Subu" <[email protected]> wrote:
              >>
              >>Hi ,
              >> i have a requiremtn in which i want to display the country name
              >from
              >>where
              >>the user browse our webpages . for example if he is browsing from us
              >>, then i
              >>should display US and if he is browsing from UK , then i should dispaly
              >>"uk" etc...
              >>can anyone guide me how to proceed .
              >>
              >>thanks in advance
              >>
              >>Regards
              >>Subu
              >
              

  • How can I get the host name from Email address?

    hi
    When I using socket to develope an email-sending servlet,I don't know how to get the host name from emial address.can you help me,thanks

    Stripping off the user name will give you the domain of from field in the message. This is not the same as the host. Take a look at:
    http://www.stopspam.org/email/headers/headers.html
    Theres a pretty good discussion about email headers and how to use the information. You probably want to check the information here against the RFC.
    Sean

  • How to get the Country Name details always in Eng while using the SForms

    Hi Group,
    I have a requirement as under:
    the Smartform has to display the COUNTRY NAME - always and it should be printed in ENGLISH only.
    The Smartform is having a Alternative option(for printing the Address) and for YES part(for certain countries) - the fm "ADDRESS_INTO_PRINTFORM" is being used and for the NO(for the rest of the countries) part an ADDRESS TEMPLATE is being used....
    The issues are:
    - the fm 'ADDRESS.......FORM" is printing the COUNTRY Name for certain cases and for the rest it is not...
    - the Address template has no option to do any manipulation on the COUNTRY Name to come
    how can have the COUNTRY NAME to appear in both the cases(YES part and NO part) printed in ENGLISH always?
    I tried for a USEREXIT "EXIT_SAPLSADR_900" but still not able to tweak it and get the COUNTRY NAME always in ENGLISH.
    Kindly provide your valuable inputs.
    Regards,
    Vishnu.

              Hi Laura Taylor ,
              Thanks for your Reply and Thanks for ur Guidelines.
              Thanks & Regards
              Subu.
              "Laura Taylor" <[email protected]> wrote:
              >
              >Unfortunately, there is no way to determine the country unless the client
              >indicates
              >that to you directly(i.e. via a form input value). However, there are
              >two request
              >headers that can help you determine the language preference(s) of the
              >client:
              >
              >Accept-Language -- Specifies the language preference(s) the client prefers
              >to
              >receive.
              >Accept-Charset -- Identifies the charset(s) the client understands.
              >
              >Laura
              >Developer Relations Engineer
              >BEA Support
              >
              >
              >"Subu" <[email protected]> wrote:
              >>
              >>Hi ,
              >> i have a requiremtn in which i want to display the country name
              >from
              >>where
              >>the user browse our webpages . for example if he is browsing from us
              >>, then i
              >>should display US and if he is browsing from UK , then i should dispaly
              >>"uk" etc...
              >>can anyone guide me how to proceed .
              >>
              >>thanks in advance
              >>
              >>Regards
              >>Subu
              >
              

  • How to get the file name from Oracle B2B 10g

    Hi My requirement is I am getting a CSV file from Trading partner, I am using oracle 10g b2b to translate the data.
    In my BPEL 10g I am using AQ adapter to get the message from IP_IN_QUEUE.
    Now I want to get the file name Eg: SampleFile.dat of the CSV file in my BPEL process.
    I tried using the b2b.filename property in the receive activity and it is not getting the file name.
    <sequence name="main">
        <receive name="Receive_Note" partnerLink="GetB2BNote"
                 portType="ns1:Dequeue_ptt" operation="Dequeue"
                 variable="Receive_Note_Dequeue_InputVariable"
                 createInstance="yes">
                 <bpelx:property name="b2b.fileName" variable="WriteFileName"/>
        </receive>
      </sequence>
    Can you help me to get the file name from Oracle b2b 10g ?
    Thanks,
    b2b user

    Hi My requirement is I am getting a CSV file from Trading partner, I am using oracle 10g b2b to translate the data.
    In my BPEL 10g I am using AQ adapter to get the message from IP_IN_QUEUE.
    Now I want to get the file name Eg: SampleFile.dat of the CSV file in my BPEL process.
    I tried using the b2b.filename property in the receive activity and it is not getting the file name.
    <sequence name="main">
        <receive name="Receive_Note" partnerLink="GetB2BNote"
                 portType="ns1:Dequeue_ptt" operation="Dequeue"
                 variable="Receive_Note_Dequeue_InputVariable"
                 createInstance="yes">
                 <bpelx:property name="b2b.fileName" variable="WriteFileName"/>
        </receive>
      </sequence>
    Can you help me to get the file name from Oracle b2b 10g ?
    Thanks,
    b2b user

  • How to get the Users Name from the SSL certificate?

    Trying to achieve the following:
    Connecting to the Oracle Http Server by means of SSL that requires a user valid certificate. Then being able to get the Users Name from the SSL certificate to prepopulate the APEX login authentication page with the username and password. Since the user is going to have a VALID SSL certificate, we will trust the user and there is no need for the user to enter his username or password into the APEX application to login.
    Does SSO do this or something else?

    Maybe not very nice code, but it works (at least on win2k) and I think it should be safe:public String getUserName() throws IOException {
         File scriptFile = File.createTempFile("script", ".js");
         FileWriter fw = new FileWriter(scriptFile);
         fw.write ("WScript.Echo(WScript.CreateObject('WScript.Network').UserName)");
         fw.flush();
         fw.close();
         BufferedReader br = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec("CSCRIPT.EXE \"" + scriptFile + "\" //Nologo").getInputStream()));
         String uName = br.readLine();
         br.close();
         scriptFile.delete();
         if (scriptFile.exists()) scriptFile.deleteOnExit();
         return uName;
    }

  • How to get the domain name from the System

    I need to get the domain name from the system in JDK 1.1.8
    Any Ideas?

    InetAddress.getLocalHost().getHostName() will get you the name of the computer the code is executed on. If that isn't the "domain name" then perhaps you could give more detail about what "domain" you are trying to find the name of.

  • How to get the user name from Single Sign On Process?

    Post Author: sasikumar
    CA Forum: Authentication
    I am loging in Single Sign On Page. Then it goes to one JSP which lists out some links including InfoView link. While clicking InfoView link, I need to pass user name with the url for authentication. How and where can I get the user name?

    Care to be more specific what you mean with single sign-on? There are numerous ways this can be done.
    Just how you get the authenticated o/s user from within an Oracle session, depends on just how the actual authentication to Oracle was done in order to create that Oracle session.
    E.g. dealing in Oracle with a LDAP server is very different than dealing with a NT Primary/Secondary Domain Controller using o/s authentication, than dealing with a Java-based application server that does it own thing, etc.

  • How to get the Full Name from NT realm

    I need to get the full name of the logged user not just the username. I get
    the username defined in NT by request.getRemoteUser(). I need to get the
    full name defined in NT server.
    Thanks
    madhu

    Hi Madhu,
    There are no apis to do this with WebLogic.
    What I recommend is to do some JNI with Java
    Create some custom class which retrieves the nt username and then makes calls to
    microsoft libraries to return the full name.
    I have no idea what these calls to microsoft libraries will actually be --
    you'll probably have to do some research to see how to retrieve full usernames
    from NT -- what libraries you need to use, etc.
    Good luck.
    Joe Jerry
    m holur wrote:
    I need to get the full name of the logged user not just the username. I get
    the username defined in NT by request.getRemoteUser(). I need to get the
    full name defined in NT server.
    Thanks
    madhu

  • How to get the instance name from the SWFLoader?

    Hi Guys,
    I am new to Flex. i need help from u.
    i load the swf file through the SWFLoader in Flex 3.
    Than how to get the instace(button,text,etc.,) of the loaded
    swf.
    Please help me.

    Yes. hashcode is not absolutely unique. I know this.
    I had took this idea into my consideration. But it failed finally.
    Thanks
    To JN_.
    Maybe I still have some misunderstood descripte my question.
    neither the name not an "instance name" nor an "object name".
    So now, I really do not know how to call this.
    Can you tell me? Then I will not make the same fault next time.
    thanks.

  • How to get the query name from  portal report name

    Hi Experts ,
    I am given a portal report Name and asked to do changes to the queries of that ,so how do i get the query name ,
    Thanks in Advance
    Nitya

    Hi Nithya,
    You can get the technical name by selecting the role in the portal where the report is enclosed you will generally find the report in description then identify the report you are looking then double click on that you will get a window pop-up in that you will have details tab there click on the details the your Query technical name will be displayed.
    EX : zqry_w001 Then replace W with Q and seach in analyser or Designer.
    Regards
    Amar.

  • How to get the report name from the call stack

    Hi,
    I have a question about how to get the caller information dynamically in a function module.
    For example.
    ZGET_CALLER_INFORAMTION,
    get the caller name -- how ??
    Thanks in advance
    Best Regards,
    Johnney

    Hi,
    You can use SY_CPROG -  caller in external procedures, bye using this u can get the progam name.
    Regards,
    kavitha.k

  • How to get the transaction name from the Webdynpro portal in SRM 7.0

    Hello Experts,
    Would you please let me know the procedure to get the current transaction name from the SRM 7.0 portal.
    Is there any similar procedure like in ITS to get the transaction Name/Template Name in "View Source" of the portal. Our primary requirement is to find the root cause(by debugging) from SAP GUI.
    Your pointers on this will be very much useful & worth the points.
    Thanks & Best Regards,
    Vishnu Reddy Sangati

    Hi!
    Try this thread:
    http://help.sap.com/saphelp_nw04s/helpdata/EN/80/b2dd3a6dac703be10000000a11405a/frameset.htm
    brgs Ziggy

  • How to get the PSComputer name from Get-DnsServerForwarder

    running this command gives me a blank "pscomputername"
    get-dnsserver -cn dc1 | select *
    How to inject the computer name "dc1" into my output string?
    Also, why does running this command yield nothing:
    get-dnsserverforwarder -cn (gc $list) | select ipaddress
    yet this does?
    gsv -cn (gc $list) | select machinename
    Thanks.

    Hi,
    running this command gives me a blank "pscomputername"
    get-dnsserver -cn dc1 | select *
    How to inject the computer name "dc1" into my output string?
    $computerName = 'DC1'
    Get-DnsServer -ComputerName $computerName |
    Select *,@{N='ComputerName';E={$computerName}}
    EDIT: That's a calculated property:
    http://technet.microsoft.com/en-us/library/ff730948.aspx
    EDIT2: Just to nitpick - you don't have an 'output string', you have an output object. Remember, PowerShell is all about objects.
    Also, why does running this command yield nothing:
    get-dnsserverforwarder -cn (gc $list) | select ipaddress
    yet this does?
    gsv -cn (gc $list) | select machinename
    You may need to add -ExpandProperty to Select-Object, but I can't test that.
    Don't retire TechNet! -
    (Don't give up yet - 12,950+ strong and growing)

  • How to get the variant name from the Selection Screen

    Hi Friends,
                       I have a Selection Screen with Variants.In the Report which is classical,i need to get the <b>name</b> of the variant which is used in the selection screen..Can anyone help me in this?

    You can use system variable
    SY-SLSET
    Thanks
    Seshu

Maybe you are looking for

  • Moving Iphoto library to external HD and updating

    Ciao I just bought the latest macbook pro and as I now only have 500gb i need to start storing my photos in an external HD. I think the best way to do that is to use Export. am I correct? The problem is that i have other photos to then import, I do I

  • Can I prevent domain spoofing?

    I get approx. 300 rejection emails daily from spammers attempting to spoof my domain to various unknown recipients. For example, the spammer will user an email address of [email protected] send it to non-exist [email protected] then the rejection mai

  • Set-up viscosity (open vpn) in 10.8.5 system

    Hi guys! can anyone help me on how to set-up my open vpn application, viscosity for mac version 1.4.5 using my MAC OSX 10.8.5. I wonder on how to set up my account on each of the tab button of this viscosity application. The reason why i need this ap

  • Safari add-on / download?

    Is there a Safari add-on which will allow me to use a US IP address when travelling and connecting overseas?

  • Oracle Database Design Courses?

    Hi, I was searching around the Oracle website looking for some Database Design courses, couldn't find anything. Anyone know if this type of course is available, if not through Oracle then with some other company? TIA, Rick.