Hai all,
I have one problem in PHP-4.0.6.
In PHP-4.0.6, I am trying to keep a Java object (jdk1.2) in session. But it is not working
The problem is, in one PHP page I have created a Java object and registered the Java instance variable in session using session_register(). In the next PHP page, if I try to call the method available in java object stored in the session variable, I got the
error 'java.lang.NullPointerException'.
Here is my PHP program:
javatest.php:
<?
session_register("objSession");
$objSession = new Java("java.util.Stack");
echo "<br>Type : " . gettype($objSession);
echo "<br>objSession : $objSession";
echo "<br>isset : " . isset($objSession);
$objSession->push("11111");
$objSession->push("22222");
$objSession->push("33333");
$objSession->push("44444");
$objSession->push("55555");
echo "<br> pop : " . $objSession->pop();
echo "<br> pop : " . $objSession->pop();
?>
<html>
<head>
<title></title>
</head>
<body>
<br>
<form action="javasession.php" method="post">
<a href="javasession.php">Next Page</a>
</form>
</body>
</html>
javasession.php:
<?
session_register("objSession");
echo "<br>Type : " . gettype($objSession);
echo "<br>isset : " . isset($objSession);
echo "<br>objSession : $objSession";
echo "<br> pop : " . $objSession->pop();
?>
If I run the javatest.php, I got the following output:
Type : object
objSession : Object
isset : 1
pop : 55555
pop : 44444
Next Page
If I click the link "Next Page", I got the following output (error):
Type : object
isset : 1
objSession : Object
Warning: java.lang.NullPointerException in javasession.php on line 7
pop :
Here I tried to print the type, object type and etc. All the values are printed correctly. But I am getting the java.lang.NullPointerException.
So it seems that the session variable points to an object but not the real java object what I have stored in the session variable.
I think this problem is due to serialization and unserialization.
If any one have any solutions regarding this problem please reply me.
Thanks in advance.
With best regards,
Senthilnathan M.