This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

export content to a text file using servlet with save dialog

 
peter tong
Ranch Hand
Posts: 245
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my application using GWT, and I plan to use servlet to export the data in gwt to a text file, but I do not know how to export the data to a text file (with a prompt of save dialog) using servelt, anyone can help?
I see some article said need to use the URL class??
 
Jinal Prakas Shah
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a simple thing. first create the file using the RPC and in return get the file name. Once you have the file name open that URL in the new window. it will do the trick.
 
peter tong
Ranch Hand
Posts: 245
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jinal Prakas Shah wrote:It's a simple thing. first create the file using the RPC and in return get the file name. Once you have the file name open that URL in the new window. it will do the trick.


How to "create the file using the RPC"?
if using ServletOutputStream.println method to create the file, then when the RPC return, it will go to onFailure.

I already give up to use RPC and use FormPanel instead. anyway, I still feel intertest if this can be done using RPC.
 
Maneesh Godbole
Saloon Keeper
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need RPC. Have your servlet stream your file (with properly constructed content type, header etc). Invoke the file as a hyperlink from your client. The save dialog would depend on the browser settings.
 
Jinal Prakas Shah
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter, why don't you create the file using normal File class in Java from the RPC servlet and then just store that file in a public location. Once you created the file Just sent that filename as String to the Front end and create a Hyperlink thats it.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic