Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Allocate exception for servlet...

843842Aug 19 2008 — edited Aug 20 2008
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();

				
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 17 2008
Added on Aug 19 2008
10 comments
938 views