The moose likes EJB and other Java EE Technologies and the fly likes LAN ID from the servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "LAN ID from the servlet" Watch "LAN ID from the servlet" New topic
Author

LAN ID from the servlet

Malli Raman
Ranch Hand

Joined: Nov 07, 2001
Posts: 312
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

Joined: Jan 23, 2002
Posts: 11962
    
    5
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).


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Oh, and regardless of how you define "LAN ID", I doubt you can deduce it from HttpServletRequest.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
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).


42
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

public java.lang.String getRemoteHost()


For getting the client host.


Groovy
Malli Raman
Ranch Hand

Joined: Nov 07, 2001
Posts: 312
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

Joined: Jul 04, 2003
Posts: 1312
Originally posted by Pradeep Bhat:


For getting the client host.



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


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

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

Joined: Oct 12, 2000
Posts: 5093
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

Joined: Jul 04, 2003
Posts: 1312
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

Joined: Nov 07, 2001
Posts: 312
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

Joined: Oct 12, 2000
Posts: 5093
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: LAN ID from the servlet