Either way you'll need to use the HTTP module and add this line to
your module XML file:
<inherits name="com.google.gwt.http.HTTP"/>
Then you need to use the HTTPRequestBuilider class. If you are sending
data to the server create it like this:
HTTPRequestBuilder builder = new
HTTPRequestBuilder(RequestBuilder.POST, "/your_server_script");
builder.setHeader("Content-type", "application/csv");
try{
builder.sendRequest( your_csv_as_a_string, new RequestCallback(){
public void onError(Request request, Throwable exception)
{ GWT.log( "error", exception ); }
public void onResponseReceived(Request request, Response response){
// success
}
});
}
catch (RequestException e){ GWT.log( "error", e); }
Notice that the POST method is used. You'll need to have a script of
servlet on the server capable on handling this post.
If you want to download a csv from the server you need to use the GET
method and handle the RequestCallback to read the results:
final String csvString = null;
HTTPRequestBuilder builder = new
HTTPRequestBuilder(RequestBuilder.GET, "/your_csv.csv");
try{
builder.sendRequest( null, new RequestCallback(){
public void onError(Request request, Throwable exception)
{ GWT.log( "error", exception ); }
public void onResponseReceived(Request request, Response response){
csvString = response.getText();
}
});
}
catch (RequestException e){ GWT.log( "error", e); }
Hope this helps!