tags:

views:

137

answers:

1

Hi

My Code is

    String url = "http: gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity";
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL
            .encode(url));



    try {
        Request request = builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                  Couldn't connect to server (could be timeout, SOP
                  violation, etc.)
            }

            public void onResponseReceived(Request request,
                    Response response) {

                System.out.println(response.getText() + "Response");

                if (200 == response.getStatusCode()) {
                    Window.alert(response.getText());
                } else {
                    Window.alert(response.getText());
                }
            }
        });
    } catch (RequestException e) {
        e.printStackTrace();
    }

i receive following error com.google.gwt.http.client.RequestPermissionException: The URL http://gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity is invalid or violates the same-origin security restriction at com.google.gwt.http.client.RequestBuilder.doSend(RequestBuilder.java:378) at com.google.gwt.http.client.RequestBuilder.sendRequest(RequestBuilder.java:254) at com.ip.client.IpAddressTest.onModuleLoad(IpAddressTest.java:46) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:369) at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222) at java.lang.Thread.run(Thread.java:619) Caused by: com.google.gwt.http.client.RequestException: (NS_ERROR_DOM_BAD_URI): Access to restricted URI denied

A: 

The "Same Origin Policy" is something that browsers implement for the user's security. If you load javascrip code from one web site, that code can't start sending requests to other web sites. It can only send requests to the same site that the code came from.

More details available at GWT docs.

If you are in control of the server that serves the gwt javascript to the browser, you can have some code on that server that sends a request to gd.geobytes.com for you.

John