Hi All
I am trying to generate a CSV report so that after generation, the client would be able to download the report to his/her machine. The jsp looks like this:
byte[] outBytes = myBean.getCSVBytes();
response.setContentType ("application/x-msexcel");
response.setHeader ("Content-Disposition", "attachment;filename=\"ComputeOrder.csv\"");
byte[] buf = outBytes;
int length = 0;
ServletOutputStream op = response.getOutputStream ();
op.write(buf,0,length);
Now the problem is that when the page is loaded, although the dialogue box is thrown for "Save/Run" application, when i save it to the local machine and open it, i dont see anything. Yes absolute blank. But if I try to print out the bytes in console, i do see output(report content).
What might be wrong?
Thanks
George
-
Downloading CSV file at client machine (5 messages)
- Posted by: Jo V
- Posted on: June 20 2003 12:15 EDT
Threaded Messages (5)
- Downloading CSV file at client machine by Dave C on June 20 2003 12:45 EDT
- Downloading CSV file at client machine by Jo V on June 20 2003 13:39 EDT
- Downloading CSV file at client machine by Sean Sullivan on June 20 2003 19:52 EDT
- Downloading CSV file at client machine by Sean Sullivan on June 20 2003 19:53 EDT
- Downloading CSV file at client machine by Jo V on June 24 2003 12:23 EDT
-
Downloading CSV file at client machine[ Go to top ]
- Posted by: Dave C
- Posted on: June 20 2003 12:45 EDT
- in response to Jo V
becuase your length variable is set to 0 and then never changed before your call to op.write(buf,0,length); That calls op.write(buf,0,0); which writes 0 bytes. -
Downloading CSV file at client machine[ Go to top ]
- Posted by: Jo V
- Posted on: June 20 2003 13:39 EDT
- in response to Dave C
Thanks a lot Dave. Also another question... how can I close the window(page on which the download took place)after the download??
Thanks in advance -
Downloading CSV file at client machine[ Go to top ]
- Posted by: Sean Sullivan
- Posted on: June 20 2003 19:52 EDT
- in response to Jo V
Additional tip:
call resp.setContentLength -
Downloading CSV file at client machine[ Go to top ]
- Posted by: Sean Sullivan
- Posted on: June 20 2003 19:53 EDT
- in response to Jo V
Another option...
Use
response.setHeader ("Content-Disposition",
"inline;filename=\"ComputeOrder.csv\"");
instead of
response.setHeader ("Content-Disposition",
"attachment;filename=\"ComputeOrder.csv\""); -
Downloading CSV file at client machine[ Go to top ]
- Posted by: Jo V
- Posted on: June 24 2003 12:23 EDT
- in response to Sean Sullivan
Thanks a lot