Using GWT with PHP through HTTPRequestObject

3 views
Skip to first unread message

Shanky

unread,
Aug 25, 2006, 9:55:54 PM8/25/06
to Google Web Toolkit
Using GWT, I have created a sample application, that interfaces with a
PHP script residing behind APACHE webserver.

I am using HTTPRequest.asyncPost() method with a URL like
http://someipaddress/process.php.

OnClick of a button, the program just tries to send a HTTPasync request
by posting the above URL..

Surprisingly, the post doen't go through at all. I mean, when I debug
this program using ECLIPSE, I could see that the
HTTPRequest.asyncPost() is doing nothing and it jjust comes out...
I tried to observe the packets sent using ethereal and there are no
packets sent out....

Please give some clues as to what the problem could be??Does this
HTTpRequest works at all??

One more interesting thing is that the generated JAVASCRIPT file
(generated by compiling the above JAVA code), does not contain even a
mention of the URL (http://someipaddress/process.php)??
I mean the javascript file should have this right in order to send the
request on click of the button??

Please help...

Ian Bambury

unread,
Aug 25, 2006, 11:03:05 PM8/25/06
to Google-We...@googlegroups.com
You can't access another domain via HTTPRequest (as I understand it) IE will moan at you and FF completely ignores you.

Shanky

unread,
Aug 26, 2006, 12:27:43 AM8/26/06
to Google Web Toolkit
Everything (browser machine and the apache server) are both on the same
domain...
Still this problem is there...

YUY0x7

unread,
Aug 26, 2006, 1:49:31 AM8/26/06
to Google Web Toolkit
If you run it in web mode, you have to have the generated files in a
relative folder in your server. There, you can provide a full URL
(including the IP) or you can leave it relative. When running in hosted
mode, you have to use full URLs. I use this code to generate my URLs
and I have no problem posting to php:

private static final String BASE_HOST = "http://localhost/project";
private static final String BASE_HOST_SCRIPT = "/project";

public static String url(String relative)
{
if (GWT.isScript())
return BASE_HOST_SCRIPT + relative;
else
return BASE_HOST + relative;
}

and I use it:

HttpRequest.asynPost(Server.url("my_file.php"), "some post data here",
myhandler)

Hope that helps

Shanky

unread,
Aug 27, 2006, 3:55:07 PM8/27/06
to Google Web Toolkit
Thanks a lot for the tips..
I was accessing a URL in a different domain..that's why
XMLHTTPRequest.open() was throwing "permission denied" exception as u
mentioned...
Thanks once again..

> ------=_Part_15683_33100614.1156561385498
> Content-Type: text/html; charset=ISO-8859-1
> X-Google-AttachSize: 1638
>
> You can't access another domain via HTTPRequest (as I understand it) IE will moan at you and FF completely ignores you. <br><br>
> <div><span class="gmail_quote">On 26/08/06, <b class="gmail_sendername">Shanky</b> &lt;<a href="mailto:sankarsha...@gmail.com">sankarsha...@gmail.com</a>&gt; wrote:</span>
> <blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br>Using GWT, I have created a sample application, that interfaces with a<br>PHP script residing behind APACHE webserver.
> <br><br>I am using HTTPRequest.asyncPost() method with a URL like<br><a href="http://someipaddress/process.php">http://someipaddress/process.php</a>.<br><br>OnClick of a button, the program just tries to send a HTTPasync request
> <br>by posting the above URL..<br><br>Surprisingly, the post doen't go through at all. I mean, when I debug<br>this program using ECLIPSE, I could see that the<br>HTTPRequest.asyncPost() is doing nothing and it jjust comes out...
> <br>I tried to observe the packets sent using ethereal and there are no<br>packets sent out....<br><br>Please give some clues as to what the problem could be??Does this<br>HTTpRequest works at all??<br><br>One more interesting thing is that the generated JAVASCRIPT file
> <br>(generated by compiling the above JAVA code), does not contain even a<br>mention of the URL (<a href="http://someipaddress/process.php)">http://someipaddress/process.php)</a>??<br>I mean the javascript file should have this right in order to send the
> <br>request on click of the button??<br><br>Please help...<br><br><br><br><br></blockquote></div><br>
>
> ------=_Part_15683_33100614.1156561385498--

Shanky

unread,
Aug 27, 2006, 3:58:13 PM8/27/06
to Google Web Toolkit
Ian,

Thanks a lot for the tips..
I was accessing a URL in a different domain..that's why
XMLHTTPRequest.open() was throwing "permission denied" exception as u
mentioned...

Thanks a lot..

Ian Bambury

unread,
Aug 27, 2006, 4:27:32 PM8/27/06
to Google-We...@googlegroups.com
No probs. I only know because I did it :-)
Reply all
Reply to author
Forward
0 new messages