|
From: <php...@li...> - 2008-05-27 16:19:21
|
Hello list,
I'm running PHP-Java-Bridge as a web application within Tomcat 5.5 and
attempting to get a request dispatcher from the PHP side in order to
forward to another application. The PHP-Java-Bridge context has its
crossContext context attribute set to true, but I can only seem to get
the current context. I'm using PHP code like the following snippet:
----%<----
<?php
$request = java_context()->getHttpServletRequest();
$response = java_context()->getHttpServletResponse();
$context = java_context()->getServletContext();
$otherContext = $context->getContext("/other-context");
$dispatcher =
$otherContext->getServletContext()->getRequestDispatcher("/other-path");
$dispatcher->forward($request, $response);
?>
----%<----
In this simplified example, the client code is attempting to call
HttpServletContext.getContext(java.lang.String) on the native servlet
context, which in my case is an instance of
org.apache.catalina.core.ApplicationContextFacade; however, the parser
php.java.bridge.Parser seems to interpret this as an invocation on the
JavaBridge instance, php.java.bridge.JavaBridge. This invocation has the
argument stripped because php.java.bridge.JavaBridge only has
getContext() [no args]. I think this may be coming out of the method
cache, but it's difficult for me to see why this is happening as we are
reading and parsing an input stream inside a method that has many entry
points, making debugging quite cumbersome. Hopefully I've provided
enough information for someone to shed some light. The bridge
application runs fine and I get back a php.java.bridge.http.Context
instance from the java_context() call, which seems fine. As well, the
object returned from java_context()->getServletContext() appears to be
some kind of opaque reference to an
org.apache.catalina.core.ApplicationContextFacade. I'm encouraged by the
following var_dump output:
object(java_InternalJava)#1678 (6) {
...
...
...
["__signature"]=>
string(49) "org.apache.catalina.core.ApplicationContextFacade"
}
Any help would be appreciated. Thanks.
Regards,
Matt
This email and any files contained therein is confidential and may contain privileged information. If you are not the named addressee(s) or you have otherwise received this in error, you should not distribute or copy this e-mail or use any of its content for any purpose. Please notify the sender immediately by e-mail if you have received this e-mail in error and delete it from your system
|
|
From: <php...@li...> - 2008-05-28 14:10:07
|
Hi,
you should be able to access the foreign context, provided that the foreign context is accessible. PHP scripts don't behave different than JSP's.
In particular the following code should work:
<?php require_once("java/Java.inc");
$request = java_context()->getHttpServletRequest();
echo java_inspect($request);
$response = java_context()->getHttpServletResponse();
$context = java_context()->getServletContext();
$otherContext = $context->getContext("/JavaBridge");
$dispatcher =
$otherContext->getServletContext()->getRequestDispatcher("/my.jsp");
$dispatcher->forward($request, $response);
?>
> the parser
> php.java.bridge.Parser seems to interpret this as an invocation on the
> JavaBridge instance, php.java.bridge.JavaBridge.
I think this is a misunderstanding. The Request$PhpNull means that you invoke a Java method with a NULL value, obtained from the previous method call. Either the "/other-context" doesn't exist or it is not accessible.
> I'm encouraged by the following var_dump output:
You can also use: echo java_inspect($java_value) :)
Regards,
Jost Boekemeier
__________________________________________________________
Gesendet von Yahoo! Mail.
Dem pfiffigeren Posteingang.
http://de.overview.mail.yahoo.com
|
|
From: <php...@li...> - 2008-05-28 14:23:07
|
Thanks for the reply. Fortunately this problem solved itself. I was not
getting an invocation on Request$PhpNull, but was actually getting an
invocation on JavaBridge, which my debugger confirmed. As you have
pointed out, I ought to have been seeing an attempt to call a method on
Request$PhpNull, because I already had a proper HttpServletContext (or
ought to have) and I was attempting to call getServletContext() on that,
which is not a defined method. The reason for the bad invocation seems
to have been that I failed to upgrade my client includes after upgrading
the backend to 5.2.2. Client was 4.3.3. Upgrading the client php include
files did the trick. Thanks for the tip about java_inspect(). Somehow I
missed that one :)
Matt
-----Original Message-----
From: php...@li...
[mailto:php...@li...] On Behalf
Of php...@li...
Sent: 28 May 2008 15:10
To: php...@li...
Subject: Re: [Php-java-bridge-users] trouble getting access to another
appcontext running as servlet
Hi,
you should be able to access the foreign context, provided that the
foreign context is accessible. PHP scripts don't behave different than
JSP's.
In particular the following code should work:
<?php require_once("java/Java.inc");
$request = java_context()->getHttpServletRequest();
echo java_inspect($request);
$response = java_context()->getHttpServletResponse();
$context = java_context()->getServletContext();
$otherContext = $context->getContext("/JavaBridge");
$dispatcher =
$otherContext->getServletContext()->getRequestDispatcher("/my.jsp");
$dispatcher->forward($request, $response); ?>
> the parser
> php.java.bridge.Parser seems to interpret this as an invocation on the
> JavaBridge instance, php.java.bridge.JavaBridge.
I think this is a misunderstanding. The Request$PhpNull means that you
invoke a Java method with a NULL value, obtained from the previous
method call. Either the "/other-context" doesn't exist or it is not
accessible.
> I'm encouraged by the following var_dump output:
You can also use: echo java_inspect($java_value) :)
Regards,
Jost Boekemeier
__________________________________________________________
Gesendet von Yahoo! Mail.
Dem pfiffigeren Posteingang.
http://de.overview.mail.yahoo.com
------------------------------------------------------------------------
-
This SF.net email is sponsored by: Microsoft Defy all challenges.
Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
php-java-bridge-users mailing list
php...@li...
https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users
This email and any files contained therein is confidential and may contain privileged information. If you are not the named addressee(s) or you have otherwise received this in error, you should not distribute or copy this e-mail or use any of its content for any purpose. Please notify the sender immediately by e-mail if you have received this e-mail in error and delete it from your system
|