From: <php...@li...> - 2006-09-16 22:04:35
|
Jost - thanks for the informative reply. I am running PHP in apache, and forwarding JSP pages (and the java bridge) through to Tomcat. So according to what you say below, that's not going to work well for me in any case. However I tried to get java_context()->getHttpServletRequest() anyway, just to experiment and see if that would get me anything interesting. Unfortunately that's raising exceptions: <?php $request = java_context()->getHttpServletRequest(); echo $request->toString(); $uri = $request->getRequestURI(); ?> displays: [o(String):"org.apache.coyote.tomcat4.CoyoteRequestFacade@1707653"] Fatal error: Uncaught [o(Exception):"java.lang.Exception: Invoke failed: [o(CoyoteRequestFacade)]->getRequestURI. Cause: java.lang.NullPointerException Responsible VM: 1.4.2_06@http://java.sun.com/" at: #-10 org.apache.coyote.tomcat4.CoyoteRequestFacade.getRequestURI (CoyoteRequestFacade.java:346) #-9 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) #-8 sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) #0 [internal function]: Java->__call('getRequestURI', Array) #1 /httpd/www.mydomain.com/htdocs/test_java_bridge.php(32): Java- >getRequestURI() #2 {main}] thrown in /httpd/www.mydomain.com/htdocs/test_java_bridge.php on line 32 Is that the expected behaviour, even considering I am forwarding the embedded php java() statements? I have a feeling that I am going to need to implement my own HttpServletRequest in any case - why, because I'll probably be implementing what used to be full JSP pages as in-page modules within a CMS (Joomla or Typo3, probably). Thus the URLs of the new system will be a lot different to the old system (the CMS will use parts of the URL for its own navigation, which I won't want to pass through to our java backend), and I will probably have to construct "fake" HttpServletRequests to match what the backend is expecting. Just out of interest, how would I get Tomcat to interpret the php pages instead of apache? - Is there an easy way to implement this with our current setup (we have stock apache running php, passing jsp pages to Tomcat on port 8080 with jk)? - Can one pass php pages through to Tomcat using the same mechanism as for JSP? - If so, would this cause much of a performance hit? Thanks for any help Cheers, Stephen Brandon On 16 Sep 2006, at 10:49, php...@li... wrote: > You haven't mentioned if you run PHP within your > servlet engine or within Apache or IIS. If you run PHP > within your servlet engine, > > $request = java_context()->getHttpServletRequest(); > > will just work. > > If you run PHP in a HTTP server and only forward the > embedded php java() statements, things will be more > difficult, because the bridge doesn't pass all > information to the back-end. For example a request > > GET http://host.com/foo/bar.php?param=... > will cause the bridge to send a HTTP PUT request: > PUT http://127.0.0.1:8080/foo/bar.phpjavabridge > > This means that you currently cannot retrieve the > method() and the params from the request. -- But the > bridge could forward them, if you need this. > > > Regards, > Jost Boekemeier |