|
From: <php...@li...> - 2010-06-22 07:43:32
|
Hi Bernard,
now I understand the problem. You cannot acquire an invocable php
script engine from the current servlet container. The only available
script engine is the PhpScriptEngine, which you cannot cast to
invocable. The invocable script engine can only call remote PHP script
methods or procedures.
The API has been removed in version 6 because I cannot think of a
real-world scenario where it is necessary to instanciate a local PHP
script and call some of its methods. You may as well use the
non-invocable PHP script engine or simply use
requestDispatcher.forward() or .include()
> ScriptEngine scriptEngine = EngineFactory.getInvocablePhpScriptEngine(
> this, getServletContext(), httpServletRequest, httpServletResponse, new URI(
> "http://127.0.0.1:8080/JavaBridge/java/JavaProxy.php" ) );
>
> should give me the script engine?
Yes. But you should be careful to not exceed the servlet engine pool size.
> How then do I use a FileReader to point to my test.php and then call a
> function (say f) within test.php?
Create a script:
<?php include("app"); echo f(); ?>
and use the EngineFactory.getPhpScriptEngine(..).eval(...) or use
<jsp:include > to invoke it.
Regards,
Jost Bökemeier
|