1 Reply Latest reply on Jul 22, 2011 2:26 AM by nimo stephan

    How does Server serve in UTF-8 ?

    nimo stephan Master

      I want to serve a jsf-page in UTF-8 and so I changed the encoding to UTF-8:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html xmlns="http://www.w3.org/1999/xhtml"

         xmlns:ui="http://java.sun.com/jsf/facelets"

         xmlns:h="http://java.sun.com/jsf/html"

         xmlns:f="http://java.sun.com/jsf/core">

       

      <head>

      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

      <title>Numberguess</title>

      </head>

       

      <body>

        <h1>Ä, Ö, Ü</h1>

      </body>

       

      But the server does not serve this page in UTF-8: The browser does not show Ä, Ö, Ü correctly.

       

      When I change UTF-8 to ISO-8859-1, then it works: Ä, Ö, Ü is shown correctly:

      <?xml version="1.0" encoding="ISO-8859-1"?>

       

      Why is that so? Should I change the encoding elsewhere in the server-config (standalone.xml) ?

       

      When bypassing JSF and serve a static example2.html-file within my war, then the utf-8-characters are also not shown correctly in a browser:

       

      <!doctype html>

      <html>

      <head>

      <meta charset="UTF-8" />

      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

      </head>

      <body>

        <h1>Ä, Ö, Ü</h1>

      </body>

       

      The strange thing is, when using httpd to transport the example2.html,then UTF-8 works. So I guess, I have to adjust the encoding anywhere in jboss as 7, but where? Or should I use always use ISO-8859-1 instead of UTF-8 in jboss?

        • 1. Re: How does Server serve in UTF-8 ?
          nimo stephan Master

          I found the reason:

           

          The file was saved by eclipse default encoding (Cp1252). I changed it to UTF-8. Now, every file is saved in UTF-8 (I hope, there are no other negative side-effects of my source-code when using UTF-8 instead of Cp1252), and with <meta charset="UTF-8" /> it works.

           

          So the reason was not a missing UTF-8-setting in Jboss AS Container but the file was not saved in the correct format.