Get LAN client machine name in servlet based web application

后端 未结 2 609
自闭症患者
自闭症患者 2020-12-20 05:53

I have spring MVC application, that runs in LAN. In there client machines IP addresses are changing time to time. Therefore I want to get client machines names(Their machine

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-20 06:34

    Is that possible to get client machine's name??

    You're probably referring to NetBIOS name here. If that's the case - you should use some library that implements NetBIOS/SMB/CIFS in java to do this.

    if it's possible how??

    Have a look on JCIFS. I won't give you the exact code snippet but this is the direction you should move to solve this.

    Or is there any other way to get that user details

    As far as I understand your problem, what you need is a way to identify host and you cannot rely on IP address for that.

    If that's the case one of the other options would be using MAC address, but you'll probably wont be able to do this with pure java since this is more low-level protocol java normally deals with, so it will probably be less portable. This tutorial might help.

    UPDATE

    I come across NetBIOS/SMB/CIFS stack but I haven't worked with it in Java and JCIFS. That's why I won't give you specific code piece that will solve your issue but rather direction where you should look.

    Check out NbtAddress class docs. Seems to be what you are looking for. Also check out the examples to get the idea how it can be used.

提交回复
热议问题