Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Jim Typrowicz
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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?
 
Tomasz Szymanski
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic