How to Get a Client's MAC Address from Httpservlet

how to get a client's MAC address from HttpServlet?

You're probably not going to get what you want. (the client's MAC address)

If the server is close enough (directly connected via hub or maybe a switch) you can ARP for the MAC Address. If you do this for an IP across the Internet you're probably going to get the inside interface of the closest Router or Switch.

Because of the way TCP/IP works the MAC address used in the 'frame' will get ripped off and re-assembled each at each hop the information takes between the server and the host.

alt text

Encapsulation

Can I get the physical address of a client in servlet?

In TCP/IP You can't get the MAC Address

Details can be found on this thread
how to get a client's MAC address from HttpServlet?

How to get client MAC address in java servlet?

Using only Servlet technologies, it is impossible to get MAC addresses. MAC address detection need software running on the client machine - a browser plugin, ActiveX control, JavaScript script or something like that. It would also most likely trigger security warnings, if the browser tried to access such information.

Cookies should be used as a first method of returning visitor detection. It is quite easy to clear them or use a different browser, but the majority of internet users don't think about such things.

Going for MAC addresses seems needlessly invasive to me.

Get MAC address from Jetty HTTPServletRequest

No, you only have the remote IP, the network layers below are out of the picture.
You'd have to resort to some ARP lookup, as matt's answered, but that is not very straightforward, specially in Java. See this related question.

How can i get MAC address of client machine in jsp

            //InetAddress address = InetAddress.getLocalHost();
InetAddress address = InetAddress.getByName("192.168.46.53");

/*
* Get NetworkInterface for the current host and then read the
* hardware address.
*/
NetworkInterface ni = NetworkInterface.getByInetAddress(address);
if (ni != null) {
byte[] mac = ni.getHardwareAddress();
if (mac != null) {
/*
* Extract each array of mac address and convert it to hexa with the
* following format 08-00-27-DC-4A-9E.
*/
for (int i = 0; i < mac.length; i++) {
System.out.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : "");
}
} else {
// Address doesn't exist or is not accessible.
}
} else {
// Network Interface for the specified address is not found.
}


Related Topics



Leave a reply



Submit