wood burning stoves*
The moose likes Servlets and the fly likes creating pdf,xml,doc file using servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "creating pdf,xml,doc file using servlet" Watch "creating pdf,xml,doc file using servlet" New topic
Author

creating pdf,xml,doc file using servlet

faisal ishaque
Greenhorn

Joined: Feb 21, 2003
Posts: 14
My question is that, in my application there is some data which can be converted into pdf,xml and doc format?
What do you reccomend that either i use xsl/xslt and xsl-fo or use third party tools for converting the data into desire format?and could i use crystal report for this purpose?
Please give me the best practices for generating different format files for client using jsp/servlets
thanks and best regards.
Faisal Ishaque
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Yes. If you want PDF's and they aren't difficult reports, I'd check out IText for creating them. It has Java Classes for creating PDFs. If you want to transform your XML into HTML, use XSLT. I don't know much about Crystal Reports class, but We use Crystal with our VB applications and it is handy.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
faisal ishaque
Greenhorn

Joined: Feb 21, 2003
Posts: 14
Thanks for giving me the helpfull suggestions...
Also tell me the performance issues using xsl/xslt/xsl-fo and third part tools?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

That's a good question. Performance seemed adequate in the couple of stuff that I have done. It is as usual, internet time.
Mark
Sean Sullivan
Ranch Hand

Joined: Sep 09, 2001
Posts: 427
Dynamically Creating PDFs in a Web Application
http://www.onjava.com/pub/a/onjava/2003/06/18/dynamic_files.html
iText (Java PDF library)
http://www.lowagie.com/iText/
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
If you use a cache to store pre-compiled XSL documents performance decrease is negligable (especially seen in the light of the typical runtime of a medium sized JSP or servlet, throw in some EJB calls and you will never even notice) after the first request that adds the compiled XSL to the cache.
I've successfully used code like the following (this is a rough draft of a version I'm working for for an upcoming new project):

as the doPost method of a servlet. 'cache' is a simple HashMap that's declared static to the servlet.
Calling entities pass a Document object and the name of an XSL stylesheet (which are assumed to be stored in /WEB-INF/xsl here).
Using similar code written for an earlier version of Xalan I clocked transformation times of 2-5 milliseconds for quite complex XSL stylesheets (with compilation taking 300 or so milliseconds, illustrating the need for caching).
About half this code is actually concerned with errorchecking, using an HTML template to generate an HTML output to display errors on the fly.
[ December 01, 2003: Message edited by: Jeroen Wenting ]

42
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi faisal,
if you want to include the Model-View-Controller pattern in your application design check out StrutsCX to generate your XML or PDF output. StrutsCX is an extension to the Apache Struts framework for use with XSLT - as alternative to JSP. It includes Apache's FOP.
http://it.cappuccinonet.com/strutscx
Regards,
Bernhard Woehrlin
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: creating pdf,xml,doc file using servlet