CAB binary data over servlet response

A

antoinelarcher

Hi folks,

Does anyone would have any idea concerning the problem described below
:
I created a servlet which sends CAB binary data on the servlet
response. The binary data is contained in a byte array.

Then, I get the file stream by using Internet Explorer for example.

The problem is that the resulting file differs from the original (the
orginal is on the server) : even if the file length is ok, some bytes
differ from the original contents. Then, when I try to read the
received cab file, I get a "file corrupted" dialog box.

Does anyone would know what would be the problem's cause ?
Any help will be appreciated.

Thank you very much,

Regards,

Antoine Larcher


____________________
I join the sample of code which sends the byte array over the response
:


private void sendResponse(ServletResponse response, byte[]
hmeContents) throws HmeException
{
BufferedOutputStream out = null;

try
{
response.setContentType("application/x-octetstream");
response.setContentLength(hmeContents.length);
out = new BufferedOutputStream(response.getOutputStream());
out.write(hmeContents);
}
catch (IOException e)
{
throw new HmeException("Cannot obtain I/O on response");
}
finally
{
try
{
if (out != null)
{
out.flush();
out.close();
}
}
catch (IOException e)
{
throw new HmeException("Error while closing response
outputStream");
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top