A
Albretch
From:
file:///C:/apps/jakarta-tomcat-4.1.18/docs/javax/servlet/ServletRequest.html#getRemoteAddr()
public java.lang.String getRemoteAddr():
Returns the Internet Protocol (IP) address of the client that sent
the request. For HTTP servlets, same as the value of the CGI variable
REMOTE_ADDR.
Returns: a String containing the IP address of the client that
sent the request
Now, this String should look like d.d.d.d for Inet4 or
FEDC:BA98:7654:3210:FEDC:BA98:7654:3210 for an Inet6 kind of address
Now, where is a method in Java which, given an IP Address returns to
you a byte[]. Four bytes in case of Inet4 and 16 in the case of Inet6?
Say, you would like to format IP Addresses you get from a client's
browser request using only 4 (or 16) bytes.
How do you combine the method getRemoteAddr() from the ServletRequest
with getAddress() from java.net.InetAddress to get the IP Address of
the remote user as a byte[] array?
The thing is that java.net.InetAddress.getAddress() gives you given a
host name, its corresponding IP address.
Of course you could always parse it off, but I think there should be
a method in the API.
Where is it?
file:///C:/apps/jakarta-tomcat-4.1.18/docs/javax/servlet/ServletRequest.html#getRemoteAddr()
public java.lang.String getRemoteAddr():
Returns the Internet Protocol (IP) address of the client that sent
the request. For HTTP servlets, same as the value of the CGI variable
REMOTE_ADDR.
Returns: a String containing the IP address of the client that
sent the request
Now, this String should look like d.d.d.d for Inet4 or
FEDC:BA98:7654:3210:FEDC:BA98:7654:3210 for an Inet6 kind of address
Now, where is a method in Java which, given an IP Address returns to
you a byte[]. Four bytes in case of Inet4 and 16 in the case of Inet6?
Say, you would like to format IP Addresses you get from a client's
browser request using only 4 (or 16) bytes.
How do you combine the method getRemoteAddr() from the ServletRequest
with getAddress() from java.net.InetAddress to get the IP Address of
the remote user as a byte[] array?
The thing is that java.net.InetAddress.getAddress() gives you given a
host name, its corresponding IP address.
Of course you could always parse it off, but I think there should be
a method in the API.
Where is it?