How to make asynch calls from hosted mode to another server

35 views
Skip to first unread message

Mr. Monster

unread,
May 31, 2006, 7:14:01 PM5/31/06
to Google Web Toolkit
Is it possible to make asynch calls from hosted mode which runs on port
8888 to another server thats running on the same machine but on another
port?

Can't use hosted mode to debug anything if it involved asynch stuff
since it fails the security part.

Scott Blum

unread,
Jun 1, 2006, 4:18:30 PM6/1/06
to Google Web Toolkit
Hi Mr. Monster,

I'm not sure whether the browsers will let you do an async call on a
different port, and it might vary from browser to browser.

Here's something you can try, though:
- Copy your html file, gwt.js, and gwt-hosted.html (*) over to the
other server, and have them served from the same path that hosted mode
would have served them from.
- Launch the shell as normal and let the app load on port 8888
- Change the address bar to use the other port and click the green
arrow

* gwt.js and gwt-hosted.html are in gwt-user.jar at
com/google/gwt/core/public

Does this work for you?
Scott

Mr. Monster

unread,
Jun 2, 2006, 12:48:47 PM6/2/06
to Google Web Toolkit
Tried a few things but it doesn't work:(

You can point the browser to another location on localhost, but then
you leave the Java compiled version of your app so you loose debugging
anyways.

It would be nice if there was an option for the Hosted mode browser to
"bypass" the security restrictions on async calls, it would make it a
lot more valuable.

Scott Blum

unread,
Jun 2, 2006, 2:22:38 PM6/2/06
to Google Web Toolkit
Hi Mr. Monster,

I just went through the process with the JSON example on Windows.
Here's the step-by-step I used:

Downloaded Jetty
(http://prdownloads.sourceforge.net/jetty/jetty-5.1.11RC0.zip). Copied
Jetty's org.mortbay.jetty.jar, commons-logging.jar, and
javax.servlet.jar into C:\sandbox\temp.

Copied contents of samples\JSON\www\com.google.gwt.sample.json.JSON
into C:\sandbox\temp\com.google.gwt.sample.json.JSON. Editted the
first string in search-results.js from "ResultSet" to "BlahSet".
Copied gwt-hosted.html into
C:\sandbox\temp\com.google.gwt.sample.json.JSON

C:\sandbox\temp>java -cp
org.mortbay.jetty.jar;commons-logging.jar;javax.servlet.jar
org.mortbay.http.HttpServer 1888

Launched IE and ran
http://localhost:1888/com.google.gwt.sample.json.JSON/JSON.html in web
mode, to verify that it was working and "BlahSet" showed up.

Went into samples\JSON directory and ran
..\..\projectCreator.cmd -eclipse JSON
..\..\applicationCreator.cmd -ignore -eclipse JSON
com.google.gwt.sample.json.client.JSON

Imported the JSON project into Eclipse, ran the JSON launch config
successfully (port 8888), clicked Search. Response shows "ResultSet".

Changed the port in my hosted browser window to 1888, hit enter,
clicked Search. Response shows "BlahSet".

Put a breakpoint on JSON.java line 67.

Clicked "Search" again.

Breakpoint, responseText shows "BlahSet".

Scott

anudeep...@gmail.com

unread,
Jun 17, 2006, 1:07:29 PM6/17/06
to Google Web Toolkit
hi ,

i want to download specific number of bytes(calculated from frontend)
from a file hosted on the webserver .
Downloading is to be done from two different ports and then i have to
show the time taken for both of them

We were using applet earlier for this.


Please guide me how to do the same thing with GWT.
How can we open httpconnections from it and download files?

Please help.

Simp

unread,
Jun 17, 2006, 2:01:01 PM6/17/06
to Google Web Toolkit
I don't think you can accomplish that. First you can't write to files
with JavaScript as far a s I know it. Second you can't connect to
different ports than the one the HTTP server was serving the script
from.

bjorn

unread,
Jun 19, 2006, 2:50:15 AM6/19/06
to Google Web Toolkit
Hi Anudeep,

We are using a package called HttpUnit to call another servlet from our
RemoteServiceServlet. The trick here is to make the HttpUnit call(s) on
the server side, since you won't be able to call servers on other ports
from the browser (for security reasons). The scope for HttpUnit is
testing (of web applications) and since it is used in a different
purpose here, I guess you have to do some extending testing of
performance before rolling it out in a "busy" environment. There are
some short code samples on the HttpUnit site:
http://httpunit.sourceforge.net/ for calling an HTTP server from within
Java code (using the WebConversation class).

Hope this at least gives you an idea how this can be done. Cheers Björn

jfdi

unread,
Jun 30, 2006, 2:27:59 PM6/30/06
to Google Web Toolkit

I just did this using a simple proxy class - I posted the source back
to this list.

http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/87d48880dbd26472

Basically put the proxy so it gets loaded by your gwt app in the hosted
bit and point it at your real server. The GWT client is happy because
its talking to the right host/port and you're also talking to the right
back-end.

Dave

Reply all
Reply to author
Forward
0 new messages