Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

binary file corrupted when downloading

843836Oct 11 2004 — edited Oct 19 2004
Hi. I'm trying to download binary files using a JSP. This is my code:

<%
response.setContentType(report.getContent_type());
response.setHeader ("Content-Disposition", "attachment;filename=\""+report.getNombre()+"\"");

byte[] file = report.getFile();

ServletOutputStream sos = response.getOutputStream();
sos.write(file);
sos.close();
%>

It seems to work, but when i'm going to open the downloaded file, it's corrupted, and when I compare it with the original one, all bytes that follow the first '\0' character have been replaced by '\0'. The file size is the same, but not the content.

I'm using Websphere as application server. Maybe this problem is related with the server, or maybe I'm doing something wrong. Any ideas?

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 16 2004
Added on Oct 11 2004
2 comments
257 views