From: <php...@li...> - 2010-07-11 12:06:12
|
> A PhpServletDecorator should provide concrete implementations of > getHttpServletRequest(), ..., to provide the values from the > closed-over environment. There's a ready-made decorator in PHP/Java Bridge 6.2.1-test1: http://php-java-bridge.cvs.sourceforge.net/viewvc/php-java-bridge/php-java-bridge/server/php/java/script/servlet/PhpCompiledHttpScriptContext.java?revision=1.1&view=markup It can be used as follows: private static final CompiledScript script = ((Compilable)(new ScriptEngineManager().getEngineByName("php-invocable"))).compile("<?php echo java_context()->get('hello'); function f($p){return (string)$p+1;};?>"); ScriptContext ctx = new php.java.script.servlet.PhpCompiledHttpScriptContext(script.getEngine().getContext(),this,application,request,response); script.eval(ctx); out.println(String.valueOf(((Invocable)script.getEngine()).invokeFunction("f", new Object[]{1}))+"<br>"); ((Closeable)script.getEngine()).close(); Please see examples http://php-java-bridge.cvs.sourceforge.net/viewvc/php-java-bridge/php-java-bridge/examples/php%2Bjsp/jsr223.jsp?view=markup&sortby=date and http://php-java-bridge.cvs.sourceforge.net/viewvc/php-java-bridge/php-java-bridge/examples/php%2Bjsp/jsp%2Bphp.jsp?view=markup&sortby=date Regards, Jost Bökemeier |