You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pham Anh Tuan <an...@ichi-corp.jp> on 2005/11/09 03:42:49 UTC

[HELP] the problem with I18n

hi all,

I got a problem with I18n, the browser couldn't automatically turn UTF-8 encoding on when jsp page is showed, so, the content is showed incorrectly :( ... If I want the content to show correctly, I must change the encoding setting of the browser to UFT-8, I tested on IE, Firefox, the result is the same above :(

so, for you clearly understand about my problem, below is my configuration:
---------------------------------------
web.xml
--------------------
<web-app>

 <!-- setting up Struts servlet   -->
 <servlet>
  <servlet-name>action</servlet-name>
  <servlet-class>
   org.apache.struts.action.ActionServlet
  </servlet-class>
  <init-param>
   <param-name>config</param-name>
   <param-value>/WEB-INF/struts-config.xml</param-value>
  </init-param>
  <init-param>
   <param-name>debug</param-name>
   <param-value>2</param-value>
  </init-param>
  <init-param>
   <param-name>detail</param-name>
   <param-value>2</param-value>
  </init-param>
  
  <init-param>
   <param-name>locale</param-name>
   <param-value>true</param-value>
  </init-param>
  
  <init-param>
   <param-name>application</param-name>
   <param-value>properties.languages_vn</param-value>
  </init-param>

  <load-on-startup>2</load-on-startup>
 </servlet>


 <!-- Map *.do files -->
 <servlet-mapping>
  <servlet-name>action</servlet-name>
  <url-pattern>*.do</url-pattern>
 </servlet-mapping>

 <session-config>
  <session-timeout>30</session-timeout>
 </session-config>

 <!-- default page load -->
 <welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
......

---------------------------------------------------
struts-config.xml
------------------------------
.........
 <global-forwards>
  <!--  go to homepage -->
  <forward name="goToHomepage" path="/vm/MyJsp.jsp"
   redirect="true" contextRelative="true" />
 </global-forwards>

 <action-mappings>
 </action-mappings>
 <message-resources parameter="properties.languages_vn" />
......

-------------------------------------------------
MyJsp.jsp
---------------------
<%@ taglib uri="struts-bean" prefix="bean" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
     <title>MyJsp.jsp</title>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    This a struts page. <br>
    <bean:message key="welcome"/>
  </body>
</html>

-------------------------------------------------
languages_vn.properties - save with UTF-8 encoding
---------------------
welcome=ひらがな



what happened :( ... help me :(

Tuan

Re: [HELP] the problem with I18n

Posted by Pham Anh Tuan <an...@ichi-corp.jp>.
Thank you Laurie Harper, my problem is solved :)

----- Original Message ----- 
From: "Laurie Harper" <la...@holoweb.net>
To: <us...@struts.apache.org>
Sent: Wednesday, November 09, 2005 10:09 AM
Subject: Re: [HELP] the problem with I18n


Two things:

1) properties files should not be saved as UTF-8. Java requires them to
be in ASCII with Unicode escapes. You can use the native2ascii utility
to convert your UTF-8 files to the correct format.

2) your JSP page needs to set the content-type to correctly identify the
encoding:

<%@ page contentType="text/html; charset=UTF-8"%>

L.

Pham Anh Tuan wrote:
> hi all,
>
> I got a problem with I18n, the browser couldn't automatically turn UTF-8 
> encoding on when jsp page is showed, so, the content is showed incorrectly 
> :( ... If I want the content to show correctly, I must change the encoding 
> setting of the browser to UFT-8, I tested on IE, Firefox, the result is 
> the same above :(
>
> so, for you clearly understand about my problem, below is my 
> configuration:
> ---------------------------------------
> web.xml
> --------------------
> <web-app>
>
>  <!-- setting up Struts servlet   -->
>  <servlet>
>   <servlet-name>action</servlet-name>
>   <servlet-class>
>    org.apache.struts.action.ActionServlet
>   </servlet-class>
>   <init-param>
>    <param-name>config</param-name>
>    <param-value>/WEB-INF/struts-config.xml</param-value>
>   </init-param>
>   <init-param>
>    <param-name>debug</param-name>
>    <param-value>2</param-value>
>   </init-param>
>   <init-param>
>    <param-name>detail</param-name>
>    <param-value>2</param-value>
>   </init-param>
>   <init-param>
>    <param-name>locale</param-name>
>    <param-value>true</param-value>
>   </init-param>
>   <init-param>
>    <param-name>application</param-name>
>    <param-value>properties.languages_vn</param-value>
>   </init-param>
>
>   <load-on-startup>2</load-on-startup>
>  </servlet>
>
>
>  <!-- Map *.do files -->
>  <servlet-mapping>
>   <servlet-name>action</servlet-name>
>   <url-pattern>*.do</url-pattern>
>  </servlet-mapping>
>
>  <session-config>
>   <session-timeout>30</session-timeout>
>  </session-config>
>
>  <!-- default page load -->
>  <welcome-file-list>
>   <welcome-file>index.jsp</welcome-file>
>  </welcome-file-list>
> ......
>
> ---------------------------------------------------
> struts-config.xml
> ------------------------------
> .........
>  <global-forwards>
>   <!--  go to homepage -->
>   <forward name="goToHomepage" path="/vm/MyJsp.jsp"
>    redirect="true" contextRelative="true" />
>  </global-forwards>
>
>  <action-mappings>
>  </action-mappings>
>  <message-resources parameter="properties.languages_vn" />
> ......
>
> -------------------------------------------------
> MyJsp.jsp
> ---------------------
> <%@ taglib uri="struts-bean" prefix="bean" %>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
>   <head>
>      <title>MyJsp.jsp</title>
>      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
>   </head>
>   <body>
>     This a struts page. <br>
>     <bean:message key="welcome"/>
>   </body>
> </html>
>
> -------------------------------------------------
> languages_vn.properties - save with UTF-8 encoding
> ---------------------
> welcome=ひらがな
>
>
>
> what happened :( ... help me :(
>
> Tuan
>
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [HELP] the problem with I18n

Posted by Laurie Harper <la...@holoweb.net>.
Two things:

1) properties files should not be saved as UTF-8. Java requires them to 
be in ASCII with Unicode escapes. You can use the native2ascii utility 
to convert your UTF-8 files to the correct format.

2) your JSP page needs to set the content-type to correctly identify the 
encoding:

<%@ page contentType="text/html; charset=UTF-8"%>

L.

Pham Anh Tuan wrote:
> hi all,
> 
> I got a problem with I18n, the browser couldn't automatically turn UTF-8 encoding on when jsp page is showed, so, the content is showed incorrectly :( ... If I want the content to show correctly, I must change the encoding setting of the browser to UFT-8, I tested on IE, Firefox, the result is the same above :(
> 
> so, for you clearly understand about my problem, below is my configuration:
> ---------------------------------------
> web.xml
> --------------------
> <web-app>
> 
>  <!-- setting up Struts servlet   -->
>  <servlet>
>   <servlet-name>action</servlet-name>
>   <servlet-class>
>    org.apache.struts.action.ActionServlet
>   </servlet-class>
>   <init-param>
>    <param-name>config</param-name>
>    <param-value>/WEB-INF/struts-config.xml</param-value>
>   </init-param>
>   <init-param>
>    <param-name>debug</param-name>
>    <param-value>2</param-value>
>   </init-param>
>   <init-param>
>    <param-name>detail</param-name>
>    <param-value>2</param-value>
>   </init-param>
>   
>   <init-param>
>    <param-name>locale</param-name>
>    <param-value>true</param-value>
>   </init-param>
>   
>   <init-param>
>    <param-name>application</param-name>
>    <param-value>properties.languages_vn</param-value>
>   </init-param>
> 
>   <load-on-startup>2</load-on-startup>
>  </servlet>
> 
> 
>  <!-- Map *.do files -->
>  <servlet-mapping>
>   <servlet-name>action</servlet-name>
>   <url-pattern>*.do</url-pattern>
>  </servlet-mapping>
> 
>  <session-config>
>   <session-timeout>30</session-timeout>
>  </session-config>
> 
>  <!-- default page load -->
>  <welcome-file-list>
>   <welcome-file>index.jsp</welcome-file>
>  </welcome-file-list>
> ......
> 
> ---------------------------------------------------
> struts-config.xml
> ------------------------------
> .........
>  <global-forwards>
>   <!--  go to homepage -->
>   <forward name="goToHomepage" path="/vm/MyJsp.jsp"
>    redirect="true" contextRelative="true" />
>  </global-forwards>
> 
>  <action-mappings>
>  </action-mappings>
>  <message-resources parameter="properties.languages_vn" />
> ......
> 
> -------------------------------------------------
> MyJsp.jsp
> ---------------------
> <%@ taglib uri="struts-bean" prefix="bean" %>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
>   <head>
>      <title>MyJsp.jsp</title>
>      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
>   </head>
>   <body>
>     This a struts page. <br>
>     <bean:message key="welcome"/>
>   </body>
> </html>
> 
> -------------------------------------------------
> languages_vn.properties - save with UTF-8 encoding
> ---------------------
> welcome=ひらがな
> 
> 
> 
> what happened :( ... help me :(
> 
> Tuan
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org