How to use Flex and Java to download files from a server?
I'm building a Flex web application where there is an option to export data from a table to a CSV format (theoreitcally, so far, haha). Since it's a web application, I assumed the best way to go about this would be to send a request to the server to generate the file, and then either send that file (or a link to it) back to the Flex application, and use a FileReference to download the file. Is this the correct way to go about this?
Could anyone give me some pointers on how to do this, however? There are some exisitng remote objects in place that call开发者_JS百科 Java functions on the server, so I thought I'd try something along those lines?
I did a bunch of research, and stumbled across things like HttpResponses and HttpServletResponses in Java, but have no idea how to bridge the gap between the client-side and server-side to use that effectively. Haha.
Thanks!
What I have done is have Flex open a new tab/window and navigate it to a servlet.
navigateToURL(new URLRequest(url),'_blank');
Then use a HttpServletResponse
to write the file out to the client, which will then be displayed in the browser. This was for a PDF, though.
In order to use an HttpServletResponse
you'll need to write a HttpServlet
and configure it in your web.xml
. Here is a basic tutorial. Google has a lot more.
精彩评论