This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Flying Saucer and Itext

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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: 43011
76
  • Mark post as helpful
  • send pies
  • 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
  • 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: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Possibly; does it work?
 
Pat Ziel
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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: 43011
76
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
The world's cheapest jedi mind trick: "Aw c'mon, why not read this tiny ad?"
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!