How to facilitate communication between php script on a server to a running Java application on another server?

后端 未结 2 1286
梦毁少年i
梦毁少年i 2021-01-23 03:28

How to establish a way for Java application to listen to data being sent by php ? Sockets or Http POST ?

Essentially, I have Java application running on another server w

相关标签:
2条回答
  • 2021-01-23 03:50

    Your best bet is probably going to be to set up a java servlet "container" (server), such as tomcat (you can pay a lot of money for something else, if you have to for corporate reasons).

    http://tomcat.apache.org/

    http://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/ServletRequest.html#getReader() or http://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/ServletRequest.html#getInputStream()

    Be aware there is a bit of work up front, just to set up and host "hello.jsp", but adding the mapping for the "myservice" servlet in web.xml is not too bad.

    0 讨论(0)
  • 2021-01-23 04:02

    I suggest implementing a REST api. If you can't or don't want to, using sockets is the most secure way...

    If you are sending FROM php, I recommend using a RESTful API with authentication. Send JSON data, get JSON data back. It allows for better future expansion too.

    0 讨论(0)
提交回复
热议问题