Results 1 to 1 of 1
  1. #1
    ModestUrgell is offline Member
    Join Date
    May 2008
    Posts
    1
    Rep Power
    0

    Default Ip adresses comparison

    I am a beginner.

    In a servlet, I need to know if the cllient address is between two adresses.

    What is the best way to do that ?

    I have done

    InetAddress addr = InetAddress.getByName("hostname1");
    byte[] adress_max = addr.getAddress();

    addr = InetAddress.getByName("hostname2");
    byte[] adress_min = addr.getAddress();

    final InetAddress address = InetAddress.getByName(request.getRemoteHost());
    final byte[] bytes = address.getAddress( );


    and then I compare the bytes.

    It works but I was wondering if there is some other way

    Modest
    Last edited by ModestUrgell; 05-30-2008 at 12:21 AM.

Similar Threads

  1. Object Comparison!
    By sajdutt in forum Advanced Java
    Replies: 6
    Last Post: 05-23-2008, 01:48 PM
  2. String comparison
    By abhiN in forum New To Java
    Replies: 2
    Last Post: 04-09-2008, 04:47 AM
  3. Comparison of Strings
    By Cero.Uno in forum New To Java
    Replies: 3
    Last Post: 02-11-2008, 02:46 AM
  4. Date comparison
    By Rageagainst20 in forum New To Java
    Replies: 0
    Last Post: 12-19-2007, 06:34 PM
  5. String comparison
    By sireesha in forum New To Java
    Replies: 1
    Last Post: 12-18-2007, 12:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •