PDA

View Full Version : Making PHP variables avaiable to Java?


EvilCensor
9-9-05, 07:45 PM
How do I make PHP variables available to Java?

I'm accessing a MySQL DB from PHP and would like to access them through a Java routine.

Any help appreciated :)

RTH10260
9-9-05, 10:10 PM
How do I make PHP variables available to Java?

I'm accessing a MySQL DB from PHP and would like to access them through a Java routine.I assume you mean you are using a Java applet at the client side (browser), as Powweb has no server side Java support.

Your applet is called (older HTML version) like this:<applet ...attributes ...>
<param name="some_name" value="some_value">
[ . . . ]
<param name="other_name" value="other_value">
</applet>
Retrieve the database content and use PHP echo statement to generate the <param> entries.

Alternate approach:
Have the Java applet request a file directly from the server using http protocol by requesting a php script that returns not a webpage but the database content in a form agreeable to the applet. You may want to feed the keys for the database access as param values to the applet, and the applet uses them as querystring in its own request.

EvilCensor
9-10-05, 06:24 AM
Yes I'm using an applet but you say..Retrieve the database content and use PHP echo statement to generate the <param> entries...sorry to ask but how do I do that?

The PHP retrieves the required data - and places them in a variable - but I'm stuck with regards actually making them visible to Java.

RTH10260
9-10-05, 05:51 PM
but I'm stuck with regards actually making them visible to Java.Sample stolen from a Java tutorial:MyApplet class import java.applet.*;
import java.awt.*;

public class MyApplet extends Applet {

public void init() {
add(new Label(getParameter("first")));
add(new Label(getParameter("second")));
add(new Label(getParameter("third")));
}
}
for this sample page:<HTML><BODY>
<<APPLET CODE ="MyApplet.class" HEIGHT=100 WIDTH=400>
<PARAM NAME="first" VALUE="1">
<PARAM NAME="second" VALUE="22">
<PARAM NAME="third" VALUE="333">
</APPLET>
</BODY></HTML>

RTH10260
9-10-05, 07:08 PM
but I'm stuck with regards actually making them visible to Java.
Ref: Sun Java tutorial on applets:
http://java.sun.com/docs/books/tutorial/uiswing/components/applet.html