I am trying to create a generic view class that is sent the file path and mimetype and the document is diplayed inline for text/pdf/doc etc and downloaded as binary for zip etc.
It works fine for all types in Firefox but pdfs don't work in IE. It looks like Acrobat Reader loads but the browser stays blank. Here is the code.

public class GenericDocView extends AbstractView
{
final static int BUFFER_SIZE = 4 * 1024; // 4K buffer

protected void renderMergedOutputModel(Map model, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception
{
String path = (String) model.get("path");
String mimeType = (String) model.get("mimeType");
File file = new File(getServletContext().getRealPath(path));
if(file.exists())
{
//returns the doc inline
httpServletResponse.setContentType(mimeType);
httpServletResponse.setHeader("Content-Disposition", "inline; filename=" + file.getName());
ServletOutputStream out = httpServletResponse.getOutputStream();
InputStream in = null;
try
{
in = new BufferedInputStream(new FileInputStream(file));
byte[] buf = new byte[BUFFER_SIZE];
int bytesRead;
while ((bytesRead = in.read(buf)) != -1)
{
out.write(buf, 0, bytesRead);
}
}
finally
{
if (in != null) in.close();
}
out.flush();
}
else
{
throw new Exception("File no longer exists on the server.");
}
}
}