726Part IVConnectionsSimilar code using (Web server logs) PHP would, by necessity,
Friday, November 30th, 2007726Part IVConnectionsSimilar code using PHP would, by necessity, be a bit more involved. Create a new PHP filecalled javatest.phpand insert the following: getProperty( java.version ); $os = $system->getProperty( os.name ); ?>
We are running Java version on the platform, and it s working!
With luck, your browser will output something like the following when you access javatest.php: We are running Java version 1.4.0 on the Linux platform, andit s working! If not, it s time to troubleshoot! Consult the PHP manual or other resources listed in AppendixD for help and suggestions. The Java objectThe Javaobject becomes available with installation of the Java extension, and is used toinstantiate a Java class within PHP. The format is: new Java(class, parameters) where classis the class being invoked and the parameters are arguments to be passed to thatobject s constructor. Parameters are optional, providing a default constructor is available. It s important to note that no Java packages are available to PHP by default. Although, as in the previous example, the java.lang.*package is always available to Java and JSP andtherefore does not need to be referenced implicitly, the complete package and class namemust always be specified from within PHP. The previous example was a simple one, since we provided no arguments to the Systemclass. Systemcannot be instantiated in Java and is referenced through static methods just as getProperty(). Let s take a look at a more involved example. With the deprecation of several Date()constructors, time reporting and formatting grew incomplexity in Java. Here s an example in which we print the current date and time in JSP: <% Calendar cr = new Calendar(); String date_time = yyyy-MM-dd HH:mm:ss ; Note44Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.