【问题标题】:How to find out a http request is sent by a local network computer or by an internet client?如何找出本地网络计算机或 Internet 客户端发送的 http 请求?
【发布时间】:2016-02-03 09:48:24
【问题描述】:

我需要一个结构来检查请求是由本地网络计算机发送还是由远程客户端通过互联网发送。

是否可以使用 httprequest 对象或 ip 地址来获取?

IF client is a local network computer
  DO 1
IF Client is a remote computer from internet
  DO 2

【问题讨论】:

  • 您可以检查反向代理的 IP 以获取 Internet 请求。
  • [stackoverflow.com/questions/6999175/…检查是否解决了您的问题
  • @Rishaldevsingh 谢谢,我知道,但我正在寻找另一种解决方案。

标签: java servlets ip httprequest subnet


【解决方案1】:

如果你有 HttpServletRequest 你可以看看

request.getRemoteAddr() 
request.getLocalAddr()

这些可用于确定客户端请求的来源。

@见http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-10-17
    • 2021-06-03
    • 2015-04-26
    • 1970-01-01
    • 1970-01-01
    • 2013-02-25
    • 2020-09-02
    相关资源
    最近更新 更多