I followed the tutorial to create the JSON PHP variant of the
Stockwatcher application. I quickly discovered that this won't work in
Hosted mode unless web.xml is modified what was to me a non-obvious
way. This information is missing from the tutorial and could be
usefully added to prevent others from having to re-invent the wheel.
With an unmodified web.xml, the built-in Jetty simply returns the text
of a requested .php file, rather than executing the .php file and
returning the output. (My Google searches showed that others had
encountered this problem, but no-one has bothered posting a solution
far as I could see.)
The solution is to modify web.xml along the lines of
<!-- Servlets -->
<servlet>
<servlet-name>PHP</servlet-name>
<servlet-class>org.mortbay.servlet.CGI</servlet-class>
<init-param>
<param-name>commandPrefix</param-name>
<param-value>"H:\Program Files\PHP\php-cgi.exe"</param-value>
</init-param>
<!-- Path, other ENV_variables including ENV_SystemRoot,
ENV_REDIRECT_STATUS on Windows -->
</servlet>
<servlet-mapping>
<servlet-name>PHP</servlet-name>
<url-pattern>*.php</url-pattern>
<!-- Any other URL patterns that are needed by your app to be
processed by PHP -->
</servlet-mapping>
but pointing to your particular PHP installation, of course.
This works as expected. However, I became ambitious, and extended the
project to use a .php script that uses MySQL. This unfortunately fails
- PHP is unable to open a socket to the MySQL server. The same script
works perfectly when called from the command line, or loaded through
IIS. It appears that the environment in which Jetty runs the script
restricts PHP's ability to use the TCP/IP stack. Now, does anyone have
a solution for this?
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.