• 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

Tomcat 6 Servlet getting error: Not an ISO 8859-1 character

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My servlet does the following:

response.setContentType("application/vnd.ms-excel; charset=UTF-8");
response.setCharacterEncoding("UTF-8");

ServletOutputStream out = response.getOutputStream();


But I get a Tomcat error stating a character is not ISO 8859-1 compliant. But since I set the character encoding to UTF-8, I don't understand why I get this message.

Any help?
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all - I don't think you should be setting any encoding for an application/vnd.ms-excel content type. You're sending a binary stream, not text, right?
But probably it has nothing to do with your exception. When exactly does it happen? Do you have any stack trace?
 
Jim Typrowicz
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply, I fixed it by simply changing

ServletOutputStream out = response.getOutputStream();

To

PrintWriter out = response.getWriter();

ServletOutputStream must not respect the character encoding for some reason.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic