?
Solved

writting pdf from jsp page

Posted on 2006-06-22
6
Medium Priority
?
446 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

752 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