Here’s a way to do post using GWT

RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, "http://localhost:9098/json/json/jsontest");
rb.setHeader("Content-Type","application/x-www-form-urlencoded");


try {
rb.sendRequest("jsontext="+hellothere.toString(), new DateCallbackHandler());


}
catch (RequestException e) {
Window.alert(e.toString());
//GWT.log("Could not send search request", e);
}


By the way, its calling a controller of a grails project.

Here’s how it handles it


def jsontest = {

String _json = (params.jsontext)?params.jsontext:’{"JSON":"servertext"}’
// String _xyz = request.inputStream.readLine();


//render _xyz

JSONObject obj = new JSONObject(_json)
render obj.getString("JSON")
}

 


Comments




Leave a Reply