aspose file tools*
The moose likes GWT and the fly likes export content to a text file using servlet with save dialog Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "export content to a text file using servlet with save dialog" Watch "export content to a text file using servlet with save dialog" New topic
Author

export content to a text file using servlet with save dialog

peter tong
Ranch Hand

Joined: Mar 15, 2008
Posts: 240
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

Joined: Jun 20, 2012
Posts: 39
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

Joined: Mar 15, 2008
Posts: 240
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

Joined: Jul 26, 2007
Posts: 10451
    
    8

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.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Jinal Prakas Shah
Ranch Hand

Joined: Jun 20, 2012
Posts: 39
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
 
subject: export content to a text file using servlet with save dialog