简体   繁体   中英

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?

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. The current hosting is not capable of running 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.
  2. Java program runs on client side, with no access or connection to PHP or the server side data stores.
  3. Java program generates a request to your server, which hits a PHP page and writes the appropriate content to the DB:

     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()? No, not possible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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