only1wizard
asked on
accessing php session variable in java
hello how do i access the php session variable in java?
java code
php code
so how will i pass a variable from php to java applet and how will i access the variable in java that was passed to the applet?
thanks in advance for your help!
Theodore E. Werntz II
java code
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
/**
* Send a POST request using URLConnection
* (Consider using HttpURLConnection or HttpsURLConnection)
*/
/**
*
* @author theodore werntz ii
*/
public class WebClientPHP {
public static void main(String[] args) {
try {
// Prepare data
String data = "UserId" ; // THIS IS THE ELEMENT I NEED TO GET FROM PHP SESSION
// Prepare connection
URL url = new URL("http://127.0.0.1/subtest.php?name="
+ data );
URLConnection connection = url.openConnection();
connection.setDoOutput(true); // Needed to write to a URLConnection
// Get the response
BufferedReader reader = new BufferedReader(
new InputStreamReader(
connection.getInputStream()));
// Print the response
String line;
while ((line = reader.readLine()) != null)
System.out.println(line);
reader.close(); // Close the reader
}
catch (Exception e) {
e.printStackTrace();
}
}
}
php code
<applet code=ComputerInfoApplet.class width="400" height="400"
ARCHIVE="ComputerInfoSepFiles.jar">
<param name="mayscript" value="true">
<param name="scriptable" value="true">
</applet>
so how will i pass a variable from php to java applet and how will i access the variable in java that was passed to the applet?
thanks in advance for your help!
Theodore E. Werntz II
ASKER
but that doesnt help the problem of accessing the php $_SESSION variable in java. I understand that accessing the variable by $_SESSION and or echo $VARIABLE.
what i dont understand is how to access the php variable in java?
thanks in advance for your help!
what i dont understand is how to access the php variable in java?
thanks in advance for your help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ive worked out a solution for cross language communication with sessions
Open in new window