My portlet application provides users with a list of documents to
download. They click a link which then streams the document bytes in
to the response and I then set the response header Content Type and
Content Disposition.

I am unfortunately having difficulty finding the appropriate
parameters in the response header.

Most content types work fine, E.G Excel and Word, but I cannot get
WinZip files to work in the same way.

I am attempting to set content Type to ‘application/zip' , and use the
filename parameter in the Content Disposition.

When I add the filename parameter, the FileType is no longer
recognized and I have to select WinZip as the application to Open the
file with.

Without the filename parameter the FileType is recognized fine and
WinZip is loaded automatically.

Has anyone had any experiences like this?

My code is attached.

Thanks
Joanne Butler

Code:
if (doc.getType().equals("zip"))
{
response.addHeader("Content-Disposition",
"attachment;filename="+ doc.getName() + "");

response.addHeader("Content-transfer-encoding" , "base64"
);

response.setContentLength(buffer.length);
response.setContentType("application/zip; name=" +
doc.getName() + ";");
ServletOutputStream outStream=response.getOutputStream();
outStream.write(buffer,0,buffer.length);
outStream.flush();
outStream.close();

}

Response Header string looks like this during debug:

{{Content-Type: application/zip; name=TestZIP;},{Content-Disposition:
attachment;filename=TestZIP},{Content-transfer-encoding:
base64},{Content-Length: 261152}}