This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Binary output, is dependent on mainly the underlying OS (in the case of something like Excel) or supporting packages called by the servlet (in the case of PDF). This is at least my understanding, having never actually done it. I have seen, especially in the XML.Apache.org site, and some related projects at Jakarta, PDF output support in XSTL. There are a number of projects doing this and the technology is most definitely servlet/jsp complementary. I would cruise/surf over to xml.apache.org and take a look at FOP.
FOP: XSL Formatting Object processor in Java FOP is the world's first print formatter driven by XSL formatting objects. It is a Java 1.2 application that reads a formatting object tree and then turns it into a PDF document. The formatting object tree, can be in the form of an XML document (output by an XSLT engine like Xalan) or can be passed in memory as a DOM Document or (in the case of Xalan) SAX events.
Timothy Stone, MIT, SCJP
"This Satan's drink [coffee] is so delicious, we shall cheat Satan and baptize it." --Pope Clement the VIII (1592-1605)
Can servlets / jsp output generate output as a .pdf file ? If yes then how can we achieve that ?
Well, I am not quite sure which of the following two questions you are asking:
Assuming that I already have a program such as StyleReport or Acrobat that builds PDF, how do I use a servlet or JSP page to make it Web-accessible?
Are there Java packages that directly generate PDF?
If you are asking the former, then the answer is straightforward, as described in Section 7.2 of the book: 1) Do 2) Call the real PDF generation tool. 3) Read the result using an input Stream and the binary method. 4) Call (not -- Writers are for character-based data) 5) Feed the binary data to the client using the method. BTW, you would use a servlet for this task, not a JSP page. JSP provides no advantages when generating binary data, only when generating character-based data that contains a mix of stuff you type in directly and dynamically-generated stuff. If you are asking the second question ("what Java packages are there that generate PDF?"), try looking at some of these sites:
Hi Bill, The link that you provide is very useful to me as well... iText make things easy, when dealing with PDF on Servlets and JSPs... Thank you very much from me too... I think Nikhil got the direct solution too...
Joined: Sep 01, 2003
Thanks everyone for their valued inputs . I am sure the iText libs would be an intresting option to try out . Regards , Nikhil