Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

LAN ID from the servlet

 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Is it possible to identify the lan id from the HttpServletRequest object?Consider that all the users are connected in the same network.

Regards,
M.S.Raman
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly is a "LAN ID"?

In any case, if it's possible at all from inside a JVM to figure out the "LAN ID" in which the JVM is running, then it should be possible to do the same from a servlet (running inside a servlet container which is running inside a JVM).
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, and regardless of how you define "LAN ID", I doubt you can deduce it from HttpServletRequest.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, you can retrieve the IP address of the machine sending the request from the ServletRequest.
Of course if the request came in via a firewall or proxy this address will be the address of that firewall or proxy and not that of the actual client machine.

Apart from that, there's no information you can get (most specifically, the MAC address of the calling machine is not available).
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public java.lang.String getRemoteHost()


For getting the client host.
 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I think we can able to retrieve only the client IP Address and not their system Local Area Network ID?

Regards,
M.S.Raman
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pradeep Bhat:


For getting the client host.



In hereal world, i thing, this method is ineficiency and not good.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by somkiat puisungnoen:



In hereal world, i thing, this method is ineficiency and not good.


Why is this inefficient ?
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Malli Raman:
Hi,

I think we can able to retrieve only the client IP Address and not their system Local Area Network ID?

Regards,
M.S.Raman


The IP address IS a unique ID on the network (or network segment).
I suggest you read up on network architecture...

And no, you can't get the MAC address of the client.
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pradeep Bhat:


Why is this inefficient ?




Because in real world , each ip (real ip) have more one machine(computer) ,
some proxy that you can not know who use this ip.
 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by somkiat puisungnoen:




Because in real world , each ip (real ip) have more one machine(computer) ,
some proxy that you can not know who use this ip.


Yes. I agree with you, It won't provide better solution.

-M.S.Raman
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by somkiat puisungnoen:




Because in real world , each ip (real ip) have more one machine(computer) ,
some proxy that you can not know who use this ip.


In the real world each IP address maps to exactly ONE (1) machine on the subnet.
That machine itself may handle requests for many machines (act as a proxy) but it's still one machine only.

There's no way around this. Even if you COULD get the MAC address you'd still get the MAC address of the proxy.
That's the definition of a proxy after all, everything behind it is a black box to everything on the other side.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic