Again, help! can one set static Java variable in php?
| From: | Tao Ye | Date: | Fri, 16 May 2003 18:10:33 +0000 |
| Subject: | Again, help! can one set static Java variable in php? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-147953@lists.php.net to get a copy of this message | ||
Hi, all,
The traffic on this mailing list is so high that I'm hoping reposting
will catch some eyeballs... Sorry to clog your mailbox but I really
would like to get some response...
I've been using both PHP and Java for a while, but just started to use the
Java extension of PHP (calling Java objects/methods in PHP). So I'm using
a PHP front end to access a Java library, with PHP4.2.3, J2sdk1.4.1 and
Apache2.
My question is, if in say, page1.php, I make a Java object, say, System,
and call setProperty("problem", "true"), should I be able to get that
property when I reload page1.php again, even though I'll re-create the
Java object again?
The code would look like:
page1.php
<?php
$testStatic = new Java('java.lang.System');
print "test static, property problem is: " .
$testStatic->getProperty("problem") . " <br>\n";
$testStatic->setProperty("problem", "true");
print "after setting prop, problem is: " .
$testStatic->getProperty("problem") . "<br>\n";
?>
Since the JVM is created only once when the first java object is created
(from a unique connection to the web server, I suppose), I don't think
it's destroyed immediately upon finishing the php page?! Shouldn't the
static variables and static methods keep its value from one execution of a
php page to the next? I don't suppose JNI load the classes and unload them
each time a php page is executed.
However, when I did this test, the static property was not persisted.
Anyone has any ideas?
Ciao,
Tao