简体   繁体   English

我将如何在JAVA和PHP之间传输数据?

[英]How would I go about Transfering data between JAVA and PHP?

I have a java application that has information that I need to display on a webpage, sorta like a chat room, The way I'm currently doing it is by having the java application listen for connections on a specific port and then I have a PHP script that connects every second to update the information listed on the page, What I'm trying to find out is there a better way of doing this? 我有一个Java应用程序,该应用程序具有需要在网页上显示的信息,就像聊天室一样,我目前的工作方式是让Java应用程序侦听特定端口上的连接,然后使用PHP每秒连接一次以更新页面上列出的信息的脚本,我试图找出的是有更好的方法吗? I haven't done anything like this before so sorry If this method is really stupid, I'm just looking for the best way to accomplish this. 我以前没有做过这样的事情,所以很抱歉,如果此方法确实很愚蠢,我只是在寻找实现此目的的最佳方法。 All constructive comments are welcome. 欢迎所有建设性意见。

EDIT: 编辑:

I forgot to mention that I'm doing this over TCP and I do not have access to MySQL so I can't store anything In a database then have the PHP script go and retrieve it.. 我忘了提到我正在通过TCP进行此操作,并且我无法访问MySQL,因此我无法将任何内容存储在数据库中,然后使用PHP脚本进行检索。

Well it depends strongly on the flow, when should the communicate? 那么这很大程度上取决于流程,什么时候应该进行沟通? If PHP needs data from Java then just do a call and parse the data back in xml's. 如果PHP需要来自Java的数据,则只需进行调用,然后将数据解析回xml。 Else if it is a lot like a chat, there should be a way to socket it, although I have never tried it. 另外,如果它很像聊天,则应该有一种方法来套接字它,尽管我从未尝试过。

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

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