2

I've been trying several examples that I've found online to have a PHP script called by an web application developed with GWT (via Eclipse) using HTTP requests. I figure once I get this to work I can apply the techniques to my own application. However, I am having a horrible time trying to get this to work. The closest that I've come to success is with the StockWatcher application found at https://developers.google.com/web-toolkit/doc/2.1/tutorial/gettingstarted (I also worked the example starting at the JSON-PHP implementation here https://developers.google.com/web-toolkit/doc/2.1/tutorial/JSONphp)

The StockWatcher example has you place a PHP script in the "war" directory. When I start with the basic example, with the following snippet defining the url string (Notes: The value for q is added after the code snippet below XXX = localhost, and YYY = 127.0.0.1:8888)

private static final String JSON_URL = GWT.getModuleBaseURL() + "stockPrices?q=";
String url = JSON_URL;

which gives the url as

"http://_YYY_/stockwatcher/stockPrices?q=";

I get at 404 error code, even if I move the PHP script to the .../war/stockwatcher directory.

If I hardcode the url:

url = YYY/stockPrices.php?q=">http://YYY/stockPrices.php?q=;

the PHP script is found but the script file is just echoed back the the client routine. This subsequently results in an exception because the client routine is expecting JSON.

Now if I change the url to

url = http://_XXX_/StockWatcher/stockPrices.php?q=;

refresh the project, copy the contents of the "war" directory to C:\wamp\www\StockWatcher, and enter XXX/stockwatcher/stockwatcher.html">http://XXX/stockwatcher/stockwatcher.html in my browser (I'm using Chrome), then everything works like a charm (I have Wampserver running on my PC).

While I might be using the Wampserver in the production system, I'd still like to debug within Eclipse. Does the built in server, Jetty, that comes with Eclipse and the GWT plugin not work with PHP?

Thanks so much in advance, Bill

appbootup
  • 9,537
  • 3
  • 33
  • 65
Bill Doss
  • 601
  • 1
  • 6
  • 13
  • +1. You would need to try configure jetty for PHP. Just for kicks will give this a try. You might find something of use here -http://stackoverflow.com/questions/5107684/jetty-server-run-php-code – appbootup Feb 13 '13 at 03:47
  • GWT dev mode with -noserver option @ http://stackoverflow.com/questions/2084103/gwt-with-noserver – appbootup Feb 13 '13 at 04:05
  • @SSR ... I accepted the answer below from Thomas. I will look into your suggestion to configure jetty for PHP. Thanks!! – Bill Doss Feb 13 '13 at 17:44

1 Answers1

2

If you're not going to deploy your app in a servlet container, then there's absolutely no reason you'd want to try running a PHP script within DevMode's servlet container.

The thing to do is:

  1. point your WAMP server at your war folder, or alternatively point the DevMode and Compiler -war at some folder served by your WAMP server
  2. start DevMode without the embedded Jetty: pass -noserver and use the http:// URL to your WAMP server as the -startupUrl (from Eclipse, use Run As → Web Application (running on external server))

See https://developers.google.com/web-toolkit/doc/latest/DevGuideCompilingAndDebugging#How_do_I_use_my_own_server_in_development_mode_instead_of_GWT%27s

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
  • Okay ... So I added `-war "C:\wamp\www\StockWatcher"` to the advanced options on the GWT Web App compile menu. Then I created a new run config with run built-in server turned off (which added `-noserver`), added a `-startUrl`, and added a `-war ...` to the arguments list. Then I copied the images directory, StockWatcher.html (& .css) to the wamp\www\StockWatcher directory. When I use the new run configuration it works!! Thanks @Thomas Broyer – Bill Doss Feb 13 '13 at 17:43