Friday, July 26, 2013

Re: how to send huge list of data to the server side from client interface in GWT

In My application I ave a front interface where the users select values and click the download button . So what ever values user is going to select will be passed to the sql query and will hit the oracle database and obtained values will be written to csv file.

Hopefully you validate the received values on the server, otherwise you might be vulnerable to SQL injection.

So, the end user should get csv file on clicking the download button. Earlier I have built this application by passing the front interface values as a query strin through window.location , But by this method we oftenly get socket connection error when the list is huge. To avoid this I have to pass the values as object to the server side and write to csv file. Do you know any way we can achieve this. if possible can u share any sample code

I pretty much always use the following workflow:
1.) Send user selection to server using GWT-RPC, RequestFactory, RequestBuilder
2.) In the UI show a message "Download link will be generated, please wait"
3.) On the server:
     - generate the file
     - generate a unique id for that file
     - save the file + the file's content type somewhere so you can find it using the unique id
     - send back a download link like<unique id>
4.) client receives download link and shows it using an Anchor.
5.) User needs to click on the anchor to download the file

To make this work you also have to: 
1.) register a http servlet at* and let it load the file and return it to the client using associated content type.
2.) regularly clear old downloads from disk/session => clean up

May sound complex, but it works really well for me.

-- J.

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment