Saturday, July 27, 2013

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

On Friday, July 26, 2013 5:06:14 AM UTC-4, Jens wrote:

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 http://domain.com/download/<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 http://domain.com/download/* 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.

I'll second Jen on this approach. I use it several places in my products and it works well. Theses apps also run a ServletContextListener to clean up old temp files. 

--
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 google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment