Hi Elyes,
something like this here should work:
OutputStream out = resp.getOutputStream();
FileInputStream fileStream = new
FileInputStream("path/to/your/excelFile.xls");
int bufferLen = 1024 * 8; // 8 KB
byte[] buffer = new byte[bufferLen];
while (true) {
int max = buffer.length;
int len = fileStream.read(buffer, 0, max);
if (len > 0)
out.write(buffer, 0, len);
else
break;
}
Bye,
Robert
elyes sallem wrote:
Hello Robert ,
so assume that i have an excel file on the server
and i have a button to download it for the client (of course with a browse
dialog)
could you show me how develop it , in your example , you call
writePDFDataToOutputStream
and it is a pdf file which is not my case
Thanks
Regards
Elyes
2008/12/15 Robert Graf-Waczenski <r...@lsoft.com>
Here's an example:
public class Downloader extends HttpServlet
{
private void doGet(HttpServletRequest req, HttpServletResponse resp) throws
IOException
{
resp.setHeader("Pragma", "no-cache");
resp.setHeader("Cache-control", "no-cache");
resp.setIntHeader("Expires", -1);
MyData data = new MyData();
resp.setHeader("content-type", "application/pdf");
resp.setHeader("content-encoding", "binary");
resp.setHeader("Content-Disposition", "attachment;
filename=myfile.pdf");
data.writePDFDataToOutputStream(resp.getOutputStream());
}
}
elyes sallem wrote:
ok, do you have an example?
Thanks
Regards
Elyes
2008/12/15 Dave Newton <newton.d...@yahoo.com>
--- On Mon, 12/15/08, elyes sallem wrote:
the problem is that with the html:file you must browse to an
existant file, but in my case, i wanna browse to a new file,
and then in the action i will make some treatment, generate
data and export them to this file
That's not how you do that.
You stream the response back and the user gets a save-file dialog.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org