From: <php...@li...> - 2007-01-04 16:24:24
|
Hi, > Am I doing something wrong when calling the > java_context() function? java_context() returns the current Java context. It is a JSR223 context if JSR223 is available. A servlet context, from which the servlet request, response, ... can be obtained, if PHP is running within a J2EE environment. Or a remote context when Java is accessed through a Apache or IIS front end or from a PHP command line binary: <?php require_once ("http://localhost:8080/JavaBridge/java/Java.inc"); $ctx = java_context(); $res = $ctx->getHttpServletResponse(); ?> In the above example $res is always null, unless the initial request came in through the tomcat port 8080. What do you want to do with the ServletRequest and ServletResponse objects anyway? When PHP is invoked from the command line or running within Apache/IIS, there's no servlet involved which could hold resonable values for the HTTP "GET/PUT/POST" method or URL parameters. > I first tried to use > java_context()->getHttpServletResponse [...] > [o(RemoteContext)]->... > *() but that returned null. Yes. RemoteContext always returns null for getHttpServletResponse etc. See http://php-java-bridge.cvs.sourceforge.net/php-java-bridge/php-java-bridge/server/php/java/servlet/RemoteContext.java?revision=1.1&view=markup > I then tried calling > java_context()->getAttribute This will not work either. The JSR223 functionality is only available if the bridge is running in a JSR223 environment: ScriptEngineManager m = new ScriptEngineManager(); ScriptEngine e = m.getEngineByName("php-invocable"); e.eval("<?php function f($p) {return 'hi '.$p;}?>"); Invocable i = (Invocable)e; Object o = i.invokeFunction("f", new Object[]{"Java"}); System.out.println(o); => hi Java Can you please explain what you want to do? Regards, Jost Boekemeier __________________________________________________ Do You Yahoo!? Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. http://mail.yahoo.com |