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");
}
}
}
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");
}
}
}