jsp get ip address

后端 未结 6 1735
挽巷
挽巷 2020-12-20 03:15

whats the best way of preventing someone from voting twice? How do i get the users ip address? What if they are on a large network? will everyone on that network show the sa

6条回答
  •  我在风中等你
    2020-12-20 04:12

    To get the IP of a client behind a router/firewall you can use request.getHeader("X-FORWARDED-FOR").

    The X-Forwarded-For (XFF) HTTP header is a de facto standard for identifying the originating IP address of a client connecting to a web server through an HTTP proxy or load balancer. http://en.wikipedia.org/wiki/X-Forwarded-For

    Keep in mind though, that this value can be changed by the proxies between you and the client. Though it should be the correct IP.

提交回复
热议问题