|
From: <php...@li...> - 2007-01-04 17:00:59
|
James,
The project you are working on definitely sounds like the type of =20
case study I want to see for the Web site to show other users (and =20
potential users) what can be done with PHP and Java using Jost's php/=20
Java bridge.
Contact me when you are ready to share your project results.
Jon Koerber
php/Java bridge Web site admin
jon...@us...
On Jan 4, 2007, at 8:42 AM, php-java-bridge-=20
us...@li... wrote:
> Thanks, Jost, for the detailed reply. It helps me understand better =20=
> how all
> of these components are working together.
>
> I had thought since the JavaBridge *was* running under Tomcat that =20
> I had
> access to everything a Servlet would as well. It seems that is not =20
> the case
> - but now I'm less certain I understand the exact relationship =20
> between PHP,
> a Java call, and Tomcat.
>
> Why do I need those java_context() objects?
>
> I'm trying to use a set of Java classes that were designed to run as a
> Servlet. (I want to use PHP to write the front-end pages and Java =20
> to do the
> "heavy lifting" in the back.)
>
> My final call to one of the class methods is
> $exportControl->processHttpdRequest($req, $resp, $servlet, null)
>
> This is supposed to write out the HTML (or other file data) =20
> directly to the
> browser. The parameters it requires are the Servlet Request, =20
> Response, and
> context objects.
>
> FWIW, if I can get this to work I'm writing it up as a case study =20
> for the
> website. It's a non-trivial implementation of PHP and Crystal =20
> Reports that
> can only be made to run by using the PHP/Java Bridge.
>
> - James
>
> On 1/4/07, php...@li... <
> php...@li...> wrote:
>>
>> 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 =3D java_context();
>> $res =3D $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-=20
>> java-bridge/server/php/java/servlet/RemoteContext.java?=20
>> revision=3D1.1&view=3Dmarkup
>>
>>
>>> 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 =3D new ScriptEngineManager();
>> ScriptEngine e =3D m.getEngineByName("php-invocable");
>> e.eval("<?php function f($p) {return 'hi '.$p;}?>");
>> Invocable i =3D (Invocable)e;
>> Object o =3D i.invokeFunction("f", new
>> Object[]{"Java"});
>> System.out.println(o);
>>
>> =3D> hi Java
>>
>>
>>
>> Can you please explain what you want to do?
>>
>>
>> Regards,
>> Jost Boekemeier
>>
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Sie sind Spam leid? Yahoo! Mail verf=FCgt =FCber einen herausragenden =
=20
>> Schutz
>> gegen Massenmails.
>> http://mail.yahoo.com
>>
>> ---------------------------------------------------------------------=20=
>> ----
>> Take Surveys. Earn Cash. Influence the Future of IT
>> Join SourceForge.net's Techsay panel and you'll get the chance to =20
>> share
>> your
>> opinions on IT & business topics through brief surveys - and earn =20
>> cash
>> http://www.techsay.com/default.php?=20
>> page=3Djoin.php&p=3Dsourceforge&CID=3DDEVDEV
>> _______________________________________________
>> php-java-bridge-users mailing list
>> php...@li...
>> https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users
>>
> ----------------------------------------------------------------------=20=
> ---
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to =20
> share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?=20
> page=3Djoin.php&p=3Dsourceforge&CID=3DDEVDEV
> _______________________________________________
> php-java-bridge-users mailing list
> php...@li...
> https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users
|