|
From: <php...@li...> - 2008-09-25 19:39:12
|
Hi,
> I am short on time right now to sort out the PUT
> permission. I'll take
Just deinstall mod_jk and it should work.
> to re-configure PHP
> to support PUT requests.
Not really. Tomcat and the PHPJavaServlet do support put, get and post requests. However, when mod_jk is installed, which is a deprecated method to connect apache with tomcat, the back end denies PUT requests in order to disallow internet clients to modify the web content.
> java-related code; where the php based front end calls a
> JAVA based backend.
You have two options: either start the built-in servlet engine with java -jar JavaBridge.jar or use a real servlet engine, for example tomcat, jetty, Oracle, IBM WebSphere, ...
[the other way 'round...]
> - I have an existing PHP based application, both backend
> and frontend.
> - I want to create a JAVA based front end that can talk to
> the PHP based
> backend
That's trivial, if you use the JSR 223 API.
For example:
jrunscript -classpath JavaBridge.jar -l php-interactive
> function toString() {return "hello Java, I am PHP";}
> echo java_closure();
=> hello Java, I am PHP
[to run the above example make sure that JavaBridge.jar and php-script.jar
is in the current working directory and that jre/lib/ext does not contain
JavaBridge.jar and php-script.jar -- Java doesn't have a module system, please
see our README section Java Platform Issues for details. Use .NET or Mono if you
don't like how Java works around that problem... ]
> * Copied the created "JavaBridge.jar" and
> "php-script.jar" from the
> "ext" folder to the J2SE library path
> (specifically the 'jre/lib/ext'
> directory)
Right.
> * opened Netbeans IDE
[...]
> public class HelloWorld {
>
> public static void main(String[] args) {
>
> String l = "3";
>
> System.setProperty("php.java.bridge.default_log_level",
> l);
>
> System.setProperty("php.java.bridge.default_log_file",
> "");
>
> System.setProperty("php.java.bridge.php_exec",
> "php-cgi");
>
> try {
> InvocablePhpScriptEngine engine = new
> InvocablePhpScriptEngine();
> String s = "<?php
> extension_loaded('java')||@dl('java.so')||@dl('php_java.dll');
> echo
> 'HelloWorld!\n';
> java_context()->call(java_closure())
> ||die('oops!');?>";
>
> engine.eval(new StringReader(s));
> String name = (String)
> ((Invocable)engine).invokeFunction("java_get_server_name",
> new Object[]{});
> System.out.println("PHP/Java communication
> port: " + name);
>
> }
>
> //engine.release();
> engine.eval((Reader)null);
>
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
> * Compiled the code, which went fine
The above example contains a try/catch statement with two closing braces. Either netbeans is a really bad programming editor or the above example is not the code you've tested.
I fixed the error and ran the following code in eclipse:
package test;
import java.io.Reader;
import java.io.StringReader;
import javax.script.Invocable;
import php.java.script.InvocablePhpScriptEngine;
public class HelloWorld {
public static void main(String[] args) {
String l = "3";
System.setProperty("php.java.bridge.default_log_level", l);
System.setProperty("php.java.bridge.default_log_file", "");
System.setProperty("php.java.bridge.php_exec", "php-cgi");
try {
InvocablePhpScriptEngine engine = new InvocablePhpScriptEngine();
String s = "<?php echo 'HelloWorld!\n'; ?>";
engine.eval(new StringReader(s));
String name = (String)
((Invocable)engine).invokeFunction("java_get_server_name", new Object[]{});
System.out.println("PHP/Java communication port: " + name);
engine.eval((Reader)null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
The result:
PHP/Java communication port: 127.0.0.1:9267
HelloWorld!
> java.lang.NullPointerException
The null pointer exception is because the eval failed. Or eval has never been called.
Regards,
Jost Boekemeier
__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.com
|