How to get client browser's ip address

Discussion in 'Java' started by Eqbal Z, Jun 7, 2004.

  1. Eqbal Z

    Eqbal Z Guest

    Hi,

    How do I get a client browser's ip address that is accessing a JSP page?
    Eqbal Z, Jun 7, 2004
    #1
    1. Advertising

  2. I don't have the documentation at hand actually
    but I remember there's a method of HttpServletRequest
    like getRemoteHost().

    So from your JSP page you can simply call
    > request.getRemoteHost()

    as "request" object is automatically given by J2EE framework!

    --
    Luca Paganelli
    ICQ# 52629494
    Luca Paganelli, Jun 7, 2004
    #2
    1. Advertising

  3. Eqbal Z

    Grant Wagner Guest

    Luca Paganelli wrote:

    > I don't have the documentation at hand actually
    > but I remember there's a method of HttpServletRequest
    > like getRemoteHost().
    >
    > So from your JSP page you can simply call
    > > request.getRemoteHost()

    > as "request" object is automatically given by J2EE framework!


    Nitpick: that does _not_ give you the IP address of "client's
    browser", since the client's browser has no IP address associated
    with it.

    More to the point: It does _not_ give you the IP address of the
    "user agent's host connecting to the server for that request". It
    gives you the IP address of the "host connecting to the server
    for that request". Sometimes those two values (the IP address of
    the user agent's host and the host connecting to the server) are
    the same. Very often they are not.

    You will not be able to uniquely identify the IP address of any
    user agent's host if that user agent is visiting your server
    through a proxy, or from behind NAT.

    When I connect to a Web site from home, REMOTE_ADDR does not
    report the IP address of the host running my user agent
    (192.168.0.192), nor does it show the external IP address
    assigned by my ISP. When I connect to a Web site from home,
    REMOTE_ADDR returns my ISP's proxy server.

    --
    | Grant Wagner <>
    Grant Wagner, Jun 11, 2004
    #3
  4. Eqbal Z

    Roedy Green Guest

    On Fri, 11 Jun 2004 17:56:36 GMT, Grant Wagner
    <> wrote or quoted :

    >
    >Nitpick: that does _not_ give you the IP address of "client's
    >browser", since the client's browser has no IP address associated
    >with it.



    see http://mindprod.com/jgloss/ip.html
    on how to get a face ip vs the machine ip.


    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jun 11, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. adnan boz

    Re: Get Client IP Address

    adnan boz, Jun 7, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    496
    Joerg Jooss
    Jun 11, 2004
  2. Tony
    Replies:
    1
    Views:
    655
    Robbe Morris [C# MVP]
    Mar 31, 2006
  3. Replies:
    1
    Views:
    6,569
    Matt Humphrey
    Jun 3, 2006
  4. Eirikur Hallgrimsson
    Replies:
    0
    Views:
    258
    Eirikur Hallgrimsson
    May 5, 2006
  5. JX
    Replies:
    5
    Views:
    583
    Mark Rae [MVP]
    Jan 23, 2008
Loading...

Share This Page