简体   繁体   English

从网站上的PHP脚本运行localhost Java Applet

[英]Run localhost Java Applet from PHP script on website

Is it possible to run a Java Applet loaded onto a users machine using a PHP script on a website and send a couple of variables from the PHP to the Applet? 是否可以使用网站上的PHP脚本运行加载到用户计算机上的Java Applet,并将几个变量从PHP发送到Applet?

This is a controlled environment that this is running in, so exploitation is not a concern. 这是一个受控制的环境,因此开发并不是一个问题。

It (the PHP) gives the applet 3 pieces of data, the applet goes out to another site that cannot be interacted with using PHP, gets the information from that site and stores it in a database. 它(PHP)为applet提供3个数据,applet转到另一个无法使用PHP交互的站点,从该站点获取信息并将其存储在数据库中。 The current hosting is not capable of running Java. 当前托管无法运行Java。

  1. PHP script serves up an applet (or a Java Web Start program - I've written a tool to make that easier in PHP: PHP JNLP generator ), and you can pass arbitrary arguments in the JNLP file, presumably also to an applet. PHP脚本提供applet(或Java Web Start程序 - 我编写了一个工具,使PHP更容易实现: PHP JNLP生成器 ),并且您可以在JNLP文件中传递任意参数,大概也可以传递给applet。
  2. Java program runs on client side, with no access or connection to PHP or the server side data stores. Java程序在客户端运行,没有访问或连接到PHP或服务器端数据存储。
  3. Java program generates a request to your server, which hits a PHP page and writes the appropriate content to the DB: Java程序向您的服务器生成一个请求,该请求访问PHP页面并将相应的内容写入数据库:

     URL url = new URL("http://example.com/storeindb.php?username=xxxxx&arg1=yyyyy&arg2=zzzzz"); new URLConnection(url).getInputStream(); 

This of course is potentially a security risk, since there's nothing stopping the client, or someone else, from loading that page as well, with whatever data they want, so you'll want to take whatever additional precautions are necessary for your use case. 这当然可能存在安全风险,因为没有任何东西可以阻止客户端或其他人加载该页面,以及他们想要的任何数据,因此您需要采取任何必要的预防措施来满足您的用例。 Any solution involving a client passing data to a server has similar risks which will need to be taken into account. 涉及客户端将数据传递到服务器的任何解决方案都存在类似的风险,需要将其考虑在内。

Running Java Applet on client machine using server-side PHP exec()? 使用服务器端PHP exec()在客户端计算机上运行Java Applet? No, not possible. 不,不可能。

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

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