> > The point I do not get about this is why the browser does not react to the > content disposition by downloading the file and instead passing the > response back to the ajax-world... <snip> ... I read a lot about that doing > what i would like to do is not possible but no one really said why.
Browsers don't allow it because it is a major security issue. If it were possible, websites would start delivering malware using these mechanisms. Many people are stupid to just click okay. There is no way to automatically trigger a file download in a browser. File download can only begin when the user explicitly takes an action - such as clicking on a link. --Sri On 27 May 2010 19:47, andreas <horst.andrea...@googlemail.com> wrote: > Hi, > > I'm trying to trigger a download via GWT rpc and/or GWT > RequestBuilder. The motivation of using rpc and/or RequestBuilder is > the ability to send data required for the on-the-fly generated > download files that way. > > I already managed to modify the underlying request by using > RequestBuilder as return value of the rpc service method. The request > is routed to a HttpServlet implementing the doPost method. GWT utility > classes are used to obtain the RPCRequest instance and the given > parameters of the rpc service call successfully out of the > HttpRequest. After using the parameters and assembling the file on the > servlet in the doPost method the HttpResponse instance is used to > write that file. Headers 'content-disposition' and 'content-type' are > set accordingly to trigger a download in the browser. > > However a download does not start. The response is accessible in the > RequestCallback instance assigned to the request. The point I do not > get about this is why the browser does not react to the content > disposition by downloading the file and instead passing the response > back to the ajax-world. I know that the rpc or request would fail > otherwise but that would be perfectly fine, since no response is > desired but a download. > > Related posts: > > http://groups.google.com/group/google-web-toolkit/browse_thread/thread/be6f95db3a4313c2/8f10a1c1e6500ccf?lnk=gst&q=download#8f10a1c1e6500ccf > > > http://groups.google.com/group/google-web-toolkit/browse_thread/thread/388e72fb8e652122/dea4693ce6642f2c?lnk=gst&q=download#dea4693ce6642f2c > > I know that there are solutions with backposts and passing data via > parameters in the request url, but i would love to just stick to one > mechanism which is GWT rpc. I read a lot about that doing what i would > like to do is not possible but no one really said why. I especially > wonder why the browser does not do its thing since it is surely the > one that gets the response before the ajax code doesn't he? > > I would like to hear about other solutions and if possible about why > exactly it is not possible to trigger download via GWT rpc. After all > escaping the GWT rpc mechanism on the server side works fine but on > the browser side not. Any ideas? > > Greetings, > Andreas > > -- > You received this message because you are subscribed to the Google Groups > "Google Web Toolkit" group. > To post to this group, send email to google-web-tool...@googlegroups.com. > To unsubscribe from this group, send email to > google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/google-web-toolkit?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.