0

I'm completely puzzled. I've set my Apache and Tomcat config files, Java Servlet project and JSP pages, ALL OF IT to "UTF-8" to support spanish characters (á, í, ó, etc). I've systematically followed all guidelines found on the documentation and forums. I know I could use Latin1, but since it seems to be easier to use UTF-8, but after 4 days of trial and error, I've decided (since my servlet will support only spanish characters) to switch to "ISO-8859-1", which is actually mostly working.

The only problem is that ONLY my JSP pages still says "UTF-8" when I right click --> Properties. The page directive and meta tag is correct (ISO-8859-1), but when I open it on the browser says "Windows-1252".

I have no idea why this is happening. If I switch to "UTF-8" (all of it, including server config, Java project, etc), the characters appears garbled at the browser, e.g.: "puntuación" instead of "puntuación".

So, to iron this question out...

Does anyone knows how to implement UTF-8 correctly and make spanish characters work everywhere?

or

Does anyone knows how to change JSP pages to be "ISO-8859-1" everywhere? Right now, it's UTF-8 at the Properties window, ISO-8859-1 as @page (contentType charset and pageEncoding) directive, and Windows-1252 at the browser

As always, I'm more than grateful in advance for your patience and support.

Diego Sagrera
  • 263
  • 5
  • 11
  • 3
    Apparently you're *saving* your JSP files using the wrong encoding. This is an editor setting, but you didn't tell anything about the editor in your question. Are you using Eclipse? Or Notepad? In any case, this article should help a lot: [Unicode - How to get the characters right?](http://balusc.blogspot.com/2009/05/unicode-how-to-get-characters-right.html) Note that you don't want to use ISO-8859-1! Just fix the UTF-8 problem and stick to it all the way. Otherwise your website is simply not ready for world domination. – BalusC Jun 13 '13 at 16:34
  • @BalusC Lol'ed at world domination. Actually I'm using NetBeans. And you're right, I don't want other than UTF-8, but it's been 4 days and I'm getting desperate. – Diego Sagrera Jun 13 '13 at 16:51
  • 1
    Ah Netbeans, sorry can't help with that in detail as I've not really used/tried it for more than 5 minutes. To the point, you need to make sure that it's been configured to save files using UTF-8 and is also using UTF-8 in the system.out.println console. For the remainder (JSP/HTTP response, HTTP GET and HTTP POST), just follow the instructions in the blog. – BalusC Jun 13 '13 at 16:54

1 Answers1

0

After adding the "CharsetFilter" class to my project, everything worked just fine.

Follow these guidelines: How to get UTF-8 working in Java webapps?

PS: I've completely removed all lines mentioning:

  1. response.setCharacterEncoding("UTF-8");
  2. response.setContentType("text/html;charset=UTF-8");

But I kept on the JSPs:

Happy coding!

Community
  • 1
  • 1
Diego Sagrera
  • 263
  • 5
  • 11