• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Flying Saucer and Itext

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey everyone,



This bit of code correctly generates a PDF file when I call it inside the main function of the class, but when I use it to generate my pdf from a JSP page I get an error about <2 of 3 Bytes and Utf8>.

The method responsible for generating the pdf is just one big block inside a static method that's being called inside the page with an array of info passed down. I'm at work atm so I can't post the stackTrace,but I thought some people might know why this is occuring.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I get an error



What is the exact text of the error - with stack trace if possible!

Where does the error message appear?

How are you accessing this? What does that have to do with the JSP forum?

Bill
 
Pat Ziel
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1- Is has to do with the JSP forum in some way due to the fact that the code works A-ONE inside a regular Java bean(From the main) and that it fails when called from A JSP page.

2- I don't have access to my computer at this moment, but the .getMessage was printing out something similar to an issue with the number of bytes and about the Utf8 format.

I will get back to you guys with a full stack trace once I get home.

P.S Something like this : Invalid byte 2 of 3-byte UTF-8 sequence
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't generate binary content (like PDF) on a JSP; you'll need to use a servlet instead.
 
Pat Ziel
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:You can't generate binary content (like PDF) on a JSP; you'll need to use a servlet instead.



Something like this?

 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Possibly; does it work?
 
Pat Ziel
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:Possibly; does it work?



I'm a bit confused here. My website is made of jsp and now I need to generate a pdf. How exactly will that servlet interact with the jsp page? Because obviously the pdf is generated with user data that is passed down from the page.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JSP containing the HTML form can submit to the servlet that creates the PDF. Or it can submit to some other servlet if that's more convenient, and the other servlet can forward to the PDF-generating servlet.
 
Pat Ziel
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well actually my code was correct. After speaking with the team we noticed the issue was with the utf8 encoding, any document that contained french accents or any other peculiar character was making it fail, so I converted the string appropriately.
 
There are 29 Knuts in one Sickle, and 17 Sickles make up a Galleon. 42 tiny ads in a knut:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic