Web tier: servlets, JSP, Web frameworks: Downloading a dynamically generated file
I am developing a J2EE application, where we will dynamically generate files in response to user requests, and make them available for download. However, if I store the file in the server's filesystem, it does not help because all the jsps/htmls available for the client is kept in a docroot directory in the web archive (war) file. It is obviously not possible to regenerate the war file. How do I overcome this problem ? I donot want to send the file back in the response, but keep it somewhere so the user can go to that link and download it.
- Posted by: Anindya Mozumdar
- Posted on: June 09 2005 12:05 EDT
Thanks in advance
Use the following code
You need not save your file and send link.
It will prompt the user to directly save the file...
stream = response.getOutputStream();
//stream.write your data