Solved

writting pdf from jsp page

Posted on 2006-06-22
6
441 Views
Last Modified: 2010-04-01
how could i write a pdf from a jsp page and open that pdf in browser...i need sample code for  that. I have tried response.setContentType("application/pdf"); but it not working .may be i am missing someting
0
Comment
Question by:sumana24
  • 2
  • 2
6 Comments
 
LVL 4

Expert Comment

by:evnafets
Comment Utility
Just setting the content type won't magically turn your HTML into a PDF document.
Content type is only an indiciation to the client of what sort of document to expect.

To generate PDF documents, you need to use a library such as IText: http://www.lowagie.com/iText/
JSPs won't help.
0
 

Author Comment

by:sumana24
Comment Utility
I have used Itext libtary also and follwoed all instructions written over there , only difference is they described the process from generating Pdf from servlet but i used jsp. I was able to create the pdf in ny local drive and render the content in that from jsp but when i am trying to open it in browser by setting content type in response it is not working...it is throwing an acrobad reader error when the respone is coming back and trying to open the pdf
0
 

Author Comment

by:sumana24
Comment Utility
it is done...ultimately i made it work
0
 
LVL 4

Accepted Solution

by:
evnafets earned 500 total points
Comment Utility
The problem is that a JSP page is designed to return plain text.
Every carriage return in a JSP file gets put into the output stream.

If you are trying to put a pdf document - or indeed any type of file out via the outputStream, those carriage returns can cause mayhem - corrupting the file.  The safest option is to do it as a Servlet - indeed that is what servlets are for.

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now