views:

359

answers:

2

Does anybody know if it is possible to have a GWT-rpc call cause a file download prompt to appear without having to do a second request to a separate servlet? I was thinking of having a method in the rpc servlet of return type void and then calling the response object directly to change the content type and cause the browser to open a download dialog.

Has anybody figured out a good way to achieve this without having a totally separate servlet?

+1  A: 

It is not possible. HERE is the similar question I had while ago

Maksim
A: 

I think you can try like this.On click of link you can do the following action.

Window.open("www.mydomain.com/downloadfile?fileId=something","_blank","");

Map the downloadfile url to some servlet and return the file.

But you cannot post data to server.You can add it in URL.In RPC call it is not possible send file.

BlackPanther
I'm using Window.Location.replace(), with a response header of 'Content-Disposition: attachment; filename=file.pdf'. It prompts a download without opening another window.
Gipsy King