jsp get ip address

后端 未结 6 1682
挽巷
挽巷 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:10

    AFAIK the ONLY way of preventing a second vote is by authenticating. Obviously this is not always possible, so you have to mitigate the possibility of a single user casting a ton of votes.

    • Throttle the voting by source IP. Use the getRemoteAddr() to allow, say... a vote per hour?... per minute? ... it will depend on how much voting you expect. Adjust the number according to experience.
    • Plant a cookie on the response for every voting poll, which expires after the ballot closes.
    • Make it harder to forge requests by checking and validating headers like Referer and User-Agent.

提交回复
热议问题