Tomcat inside JBoss
I have a servlet, which generates pdf files to be displayed inside the browser. It works all the time in standalone Tomcat 5.5, but I can't find an answer why it is erratic inside JBoss.
After the servlet is run, JBoss returns an inconsistent and usually bad http response mime type to the browser. Mostly it becomes "application/octet-stream" instead of "application/pdf" which I explicitly set. But not always... This is the output part:
ServletOutputStream out = res.getOutputStream();
res.setContentType("application/pdf");
res.setContentLength((int)outfile.length());
bis = new BufferedInputStream(new FileInputStream(outfile));
bos = new BufferedOutputStream(out);
byte[] buff = new byte[2048];
int bytesRead;
while(-1 != (bytesRead = bis.read(buff, 0, buff.length)))
{
bos.write(buff, 0, bytesRead);
}
bos.flush();
bos.close();
|