I have a number of places where the user can download a servlet generated file. I handle this generically with several steps
<!-- Frame for downloading files without opening a new window. -->
<iframe src="javascript:''" id="__gwt_downloadFrame" style="width:0;height:0;border:0"></iframe>
2) In my app's EntryPoint, I declare
private static final String DOWNLOAD_IFRAME = "__gwt_downloadFrame";
private static Frame downloadFrame;
...
Wrap the IFRAME:
@Override
public void onModuleLoad() {
downloadFrame = Frame.wrap(Document.get().getElementById(DOWNLOAD_IFRAME));
...
Provide method for downloading
public static void downloadURL(String url) {
downloadFrame.setUrl(url);
}
3) Whenever a download is ready, say in the onSuccess() of an RPC call
MyApp.downloadURL(url);