View Full Version : Reading JSON data from a local servlet with HttpProxy. How to?

7 Jan 2011, 2:56 AM
I'm working with eclipse.
I want to work with JSON using GXT HttpProxy getting data from a servlet inside the same project.
I tried but nothing works.

I created a project using the JSON grid sample provided by Sencha team. It works and reads data from a local file named data.json.
Next step is to load data from a servlet located inside the same project.
I created a servlet that makes some JSON data. It also appears inside my web.xml file as usual.

The GXT code in order to read data coming from the servler is:

String path = "http://localhost:8080/ProvaJson/servlet/JsonResponder";

// use a http proxy to get the data
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, path);
HttpProxy<String> proxy = new HttpProxy<String>(builder);

where tha path variable is the path to reach my servlet that provides json data.

now my questions are:
Do I have to run the project as a common web project? If I do that, the servlet runs correctly but the EntryPoint is stopped.
If I run the project as a GAE application, the EntryPoint runs but my servlet is stopped.

How I can bind the two environments GXT and servlet together?

What I have to do if I want to deploy with a Tomcat server?
Thank you.


7 Jan 2011, 6:41 AM
I solved the problems above.
At the same now I discovered that the server providing JSON data has to provide them in the format

transId0(...json data...);

Can anyone explain me why and a java servlet example?
thank you

25 Jan 2011, 3:25 AM
The transId is not used in HttpProxy, but in ScriptTagProxy.
Did you change to ScriptTagProxy to make is work? Maybe to get around SOP?