Re: Generate a file in J2EE application and place it to client IE's temp folder
Saturday, March 1, 2008 10:58 AM
Generate your file. Return a response, from some request, containing a page with a link that refers to the file. (maybe you'll first generate the file, and then return the response, both in your handling of the same request? or maybe not, maybe some other thread/etc. has already generated the file?)
Better variation: instead of providing a link that just refers to the static file URL (requiring you to mess with the app server's local filesystem), instead have the link invoke a servlet or action etc., which will stream the generated content to the response output stream.
Hope the user is using IE instead of a better browser like Firefox. Entice them to click on your link, thereby downloading a copy of your file, into their IE temp cache dir.
If you are sending the content to the outputstream, instead of just referring to a static file, then you probably want to set the response header "content-disposition", to encourage the browser to save to a local tmp file instead of trying to just handle the content onscreen.
(if you are just referring to a static file in the URl for the link that the user clicks, then you have no control over whether their browser decides to try handling the content onscreen instead of saving to a local tmp file)