Hello,
Thanks for your help...
My servlet returns files, it has been working fine all the time but now I added the code below so I am getting an "Allocate exception for servlet" I have no idea what is this about as the servlet compiles successfully, could you help me to find the error?
// take the message from the URL or create default message
String msg = req.getParameter("attachment");
if (msg == null || msg.trim().length() <= 0)
msg = "[ specify a message in the 'msg' argument on the URL ]";
// create simple doc and write to a ByteArrayOutputStream
Document document = new Document();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter.getInstance(document, baos);
document.open();
document.add(new Paragraph(msg));
document.add(Chunk.NEWLINE);
//document.add(new Paragraph("The method used to generate this PDF was: " + methodGetPost));
document.close();
// setting some response headers
resp.setHeader("Expires", "0");
resp.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
resp.setHeader("Pragma", "public");
// setting the content type
resp.setContentType("application/pdf");
// the contentlength is needed for MSIE!!!
resp.setContentLength(baos.size());
// write ByteArrayOutputStream to the ServletOutputStream
ServletOutputStream out = resp.getOutputStream();
baos.writeTo(out);
out.flush();