简体   繁体   English

如何知道JSP中的远程IP地址

[英]How to know Remote IP Address in JSP

I have web application through which payment transactions will happen. 我有一个Web应用程序,通过它可以进行付款交易。

The flow of the Application 申请流程

User will open my application and click the pay button. 用户将打开我的应用程序,然后单击付款按钮。 Now i will redirect the request to Payment Gateway provider (ICICI, EBS, PayPal etc). 现在,我将把请求重定向到支付网关提供商(ICICI,EBS,PayPal等)。 Now, the payment gateway provider pages will appear in my website. 现在,支付网关提供商页面将出现在我的网站中。 Now the payment process will go through, and Payment gateway provider will post their response to my application(to JSP page). 现在,付款过程将完成,并且付款网关提供商将把他们的回复发布到我的应用程序(到JSP页面)。 After capture the response i will process the request. 捕获响应后,我将处理请求。

My requirement 我的要求

How can i know the ICICI, PayPal or EBS server ip address when they call my JSP. 当他们呼叫我的JSP时,我怎么知道ICICI,PayPal或EBS服务器的IP地址。 If i call request.getRemoteAddr() it will give the client IP address. 如果我调用request.getRemoteAddr() ,它将提供客户端IP地址。 I want to know the IP address of payment gateway server. 我想知道支付网关服务器的IP地址。

Provider is posting the data as GET instead of POST. 提供者将数据发布为GET而不是POST。 Here i didnt mention my acutal payment gateway provider. 在这里,我没有提到我的自动付款网关提供商。

In general, you can only know this without help from the payment provider if 通常,只有在以下情况下,您才能在没有付款提供商帮助的情况下了解此信息:

  • there are no proxies between you and the provider, and 您与提供者之间没有代理,并且
  • the provider sends a HTTP POST (or similar) directly to you 提供商直接向您发送HTTP POST(或类似消息)

In that case ServletRequest.getRemoteAddr() should give you the provider's address. 在这种情况下, ServletRequest.getRemoteAddr()应该给您提供者的地址。

If you get the client browser's address instead, then probably the provider does not send the POST directly to you, but instead instructs the client browser to send it (most likely using Javascript). 如果你的客户端浏览器的地址,而不是,则可能是供应商直接将快递给你,而是指示客户端浏览器发送(最有可能使用Javascript)。 In that case, there is no way for you to find out the address the provider was sending from. 在这种情况下,您将无法找到提供商所发送的地址。


At any rate, why do you need to know the payment provider's IP address? 无论如何,您为什么需要知道支付提供商的IP地址? You redirect to the provider yourself, so you already have the address, don't you? 您自己重定向到提供者,所以您已经有了地址,不是吗?

Maybe you could explain in more detail what the flow of data is between you, the client browser and the payment provider, and why you want to know the provider's IP address? 也许您可以更详细地说明您,客户端浏览器和付款提供商之间的数据流,以及为什么要知道提供商的IP地址? Maybe then we can help better. 也许那时我们可以提供更好的帮助。

For PayPal you can use IPN 对于PayPal,您可以使用IPN
https://www.paypal.com/ipn https://www.paypal.com/ipn

Instant Payment Notification (IPN) is PayPal's message service that sends a notification when a transaction is affected. 即时付款通知(IPN)是PayPal的消息服务,当交易受到影响时会发送通知。 Once IPN is integrated, sellers can automate their back office so they don't have to wait for payments to come in to trigger order fulfillment. 集成IPN后,卖家可以使后台自动化,因此他们不必等待付款来触发订单履行。

With IPN you get a POST/GET call to your IPN url from the PayPal servers. 使用IPN,您可以从PayPal服务器获得对您的IPN网址的POST / GET调用。 This means that the customer does not have to return to your website after paying and you do not have to validate the customer data - instead, the PayPal servers do a 3-way handshake: they send you the payment data, you send back a check, and they validate the check that the data you have is correct. 这意味着客户付款后不必回到您的网站,也不必验证客户数据-而是,PayPal服务器进行3次握手:他们向您发送付款数据,您向您发送支票,并且他们验证检查您所拥有的数据是否正确。 In this case the server ip is the originating ip from the http call. 在这种情况下,服务器IP是http呼叫的始发IP。

Other services will probably have something similar to this. 其他服务可能与此类似。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM