• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Error in opening pdf through jsp

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my application when a button is clicked in jsp to open a pdf file,
adobe reader returns the following error -
'There was an error opening the document. The file is damaged and could not be repaired.'


note:- Some time the pdf luckly goes open at 3/10 attempts ratio.

Is this a bug in adobe or any point our application is missing?
Whether this can be a result of load on server?

 
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use a servlet not a JSP. JSPs are meant to server text resources not binary.
 
Bear Bibeault
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read this article for why.
 
siddharth paul
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the wonderfull article.

I read the part

"Why does everyone tell me to use a servlet to send binary data to the browser? I wanna use a JSP!"



The problem is i can't change the application model because of insufficiant access only can fix the bugs.
Can we sure it's because application is sending binary data to the browser in a jsp?
 
Bear Bibeault
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

siddharth paul wrote:Can we sure it's because application is sending binary data to the browser in a jsp?


PDFs are binary, so yes.
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Go through below links.

Library for generating pdf's in java

http://www.lowagie.com/iText/

An example of using iText to generate a PDF file can be found at http://www.avajava.com/tutorials/lessons/how-do-i-write-to-a-pdf-file-using-itext.html.

An example of serving up a PDF file from a servlet can be found at http://www.avajava.com/tutorials/lessons/how-do-i-serve-up-a-pdf-from-a-servlet.html.


Cheers!!!

Ujjwal B Soni

<baroda>
<gujarat>
<india>
<919998971048>
 
Bear Bibeault
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ujjwal soni wrote:Library for generating pdf's in java


He's not generating PDFs -- just serving existing ones.

The issue is the inappropriate use of JSP to server binary data.
 
siddharth paul
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to you all for your wonderfull suggestion.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic