KJW
KJW

Reputation: 15251

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

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 waiting for certain string data sent by PHP script running on other server.

Any library suggestions or example codes will be appreciated.

Upvotes: 2

Views: 1228

Answers (2)

Roboprog
Roboprog

Reputation: 3144

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.

Upvotes: 1

sethvargo
sethvargo

Reputation: 26997

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.

Upvotes: 2

Related Questions