Solved

writting pdf from jsp page

Posted on 2006-06-22
6
444 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 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
java cyclic graphs 15 221
maven webservice projet error 6 80
memory representation of int[][][] a=new int[2][][]; 10 60
servlet example 17 59
Read  the original post  on Monitis Blog. Hi.  My name is Erik Dietrich, and this is the first time I’ve posted on the Monitis blog.  By way of introduction, I thought it would make sense to talk about my initial experience with Monitis.   Befo…
In order to fulfill our mission of inspiring learning in the technology community, Experts Exchange is launching a Course of the Month program. Premium and Team Account members will have access to one course per month as a part of their membership, …

726 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