?
Solved

writting pdf from jsp page

Posted on 2006-06-22
6
Medium Priority
?
448 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 4

Expert Comment

by:evnafets
ID: 16964375
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
ID: 16968568
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
ID: 16973904
it is done...ultimately i made it work
0
 
LVL 4

Accepted Solution

by:
evnafets earned 2000 total points
ID: 16976986
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What monsters are hiding in your child's room? In this article I will share with you a tech horror story that could happen to anyone, along with some tips on how you can prevent it from happening to you.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

650 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