title: JSP property file read
body: <p>I am making one web application. In this application i am using <code>maven</code>, <code>Spring framework</code>, <code>Hibernate framework</code>, <code>JSP</code>, <code>Apache tiles</code>.</p>
  
  <p>Still this application is in English language. So now my requirement is convert application is in Portuguese language. So i create one properties file for Portuguese language and use this properties file when require.</p>
  
  <p>In my application create two properties file,<br>
  1 for english language(<code>messages.properties</code>), 2 for portuguese language(<code>messages_pt.properties</code>)</p>
  
  <p>In my jsp page when i fetch value from <code>messages.properties</code> file at that time working properly but when fetch from <code>messages_pt.propertie</code>s file at that time not working properly because in <code>messages_pt.properties</code> file contains some special character </p>
  
  <p>see my both properties file</p>
  
  <pre><code>messages.properties
      gas=Gas
  
  messages_pt.properties
      gas=Gás
  </code></pre>
  
  <p>Now come to my question...</p>
  
  <p>In JSP page i am using <code>fmt tag library</code> for read value by key from properties file
  my jsp page is like this</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%&gt;
  &lt;%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
          ..............
      &lt;/head&gt;
      &lt;body&gt;
          ..............
          &lt;fmt:message key="gas" /&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>so when fetching value for <code>gas</code> key from <code>messages_pt.properties</code> file at that time getting <code>G�s</code> value.</p>
  
  <p>I search solution in google and getting some solution but no one can solve my problem</p>
  
  <p>I am applying below solution</p>
  
  <p>1) In JSP page i add contentType in  first line and in meta tag. Please see my jsp page above.</p>
  
  <p>2) I added <code>CharacterEncodingFilter</code> in <code>web.xml</code> file and this filter is in first filter from start page.</p>
  
  <pre><code>&lt;filter&gt;  
          &lt;filter-name&gt;encodingFilter&lt;/filter-name&gt;  
          &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt;  
          &lt;init-param&gt;  
             &lt;param-name&gt;encoding&lt;/param-name&gt;  
             &lt;param-value&gt;UTF-8&lt;/param-value&gt;  
          &lt;/init-param&gt;  
          &lt;init-param&gt;  
             &lt;param-name&gt;forceEncoding&lt;/param-name&gt;  
             &lt;param-value&gt;true&lt;/param-value&gt;  
          &lt;/init-param&gt;  
      &lt;/filter&gt;  
      &lt;filter-mapping&gt;  
          &lt;filter-name&gt;encodingFilter&lt;/filter-name&gt;  
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;  
      &lt;/filter-mapping&gt; 
  </code></pre>
  
  <p>3) I added <code>defaultEncoding</code> in <code>messageSourceBean</code> in <code>xxx-servlet.xml</code> file</p>
  
  <pre><code>&lt;bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"&gt;
          &lt;property name="basenames"&gt;
              &lt;list&gt;
                  &lt;value&gt;classpath:properties/messages&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
          &lt;property name="defaultEncoding" value="UTF-8"/&gt;
          &lt;property name="useCodeAsDefaultMessage" value="true"/&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>4) I added <code>project.build.sourceEncoding</code> in <code>pom.xml</code> file.</p>
  
  <pre><code>&lt;properties&gt;
       &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
       .......
  &lt;/properties&gt;
  </code></pre>
  
  <p>5) I tried below code</p>
  
  <pre><code>&lt;%@taglib uri="http://www.springframework.org/tags" prefix="spring"%&gt; 
  &lt;p&gt;&lt;spring:message code="label.menu"/&gt;&lt;/p&gt;
  </code></pre>
  
  <p>But now can solve my problem.</p>
  
  <p>If anybody know any other solution then please tell me.</p>