2

Below is my codes, everything works fine but the fmt not.

web.xml

 <jsp-config>       
        <taglib>
            <taglib-uri>/WEB-INF/tags/jstl-fmt.tld</taglib-uri>
            <taglib-location>/WEB-INF/tags/fmt.tld</taglib-location>
        </taglib>
        <taglib>
            <taglib-uri>/WEB-INF/tags/jstl-fmt-1_0.tld</taglib-uri>
            <taglib-location>/WEB-INF/tags/fmt-1_0.tld</taglib-location>
        </taglib>
         <taglib>
            <taglib-uri>/WEB-INF/tags/jstl-fmt-1_0-rt.tld</taglib-uri>
            <taglib-location>/WEB-INF/tags/fmt-1_0-rt.tld</taglib-location>
        </taglib>
         <taglib>
            <taglib-uri>/WEB-INF/tags/jstl-c.tld</taglib-uri>
            <taglib-location>/WEB-INF/tags/c.tld</taglib-location>
        </taglib>
        <taglib>
            <taglib-uri>/WEB-INF/tags/jstl-c-1_0.tld</taglib-uri>
            <taglib-location>/WEB-INF/tags/c-1_0.tld</taglib-location>
        </taglib>
         <taglib>
            <taglib-uri>/WEB-INF/tags/jstl-c-1_0-rt.tld</taglib-uri>
            <taglib-location>/WEB-INF/tags/c-1_0-rt.tld</taglib-location>
        </taglib>
   </jsp-config>

Sample.jsp

<%@ taglib uri="/WEB-INF/tags/jstl-fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tags/jstl-c.tld" prefix="c" %>

  <html:form action="/UserAction.do">
    <fmt:message key="message.username"/>
    <c:out value="Hello" />
 </html:form>

ApplicationResource.properties

message.username=Username

tags directory

\projectName\web\WEB-INF\tags

Tags Result

 Hello // from core
    ???message.username??? //the fmt:message.username not working

Could anyone help me out, why fmt didn't works ? I have tried creating 3 or more projects with using jstl. All the jstl is working but only the fmt not.

gjman2
  • 912
  • 17
  • 28

1 Answers1

5

Finally I solved it. Following codes have to be inserted in web.xml

<context-param>
        <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
        <param-value>com.projectName.resources.ApplicationResource</param-value>
</context-param>   
gjman2
  • 912
  • 17
  • 28
  • I am trying to use your solution. I have the same problem. Is the com.projectName supposed to read exactly like that or is it supposed to be the name of my project? If my project, where can it be found? – Anonymous Human Sep 13 '17 at 17:24
  • Thanks for your reply, what is the path of your ApplicationResources file within your project? Also where do you find the project name? – Anonymous Human Sep 14 '17 at 02:00
  • As you can see the answer above, the path is com.projectName.resources and the projectName may not be your exactly your project name. It can be any name eg: com.home.town.resources. It just a path name. In my case, i used my project name to create the resources path. – gjman2 Sep 14 '17 at 02:21
  • When this finally worked for you, what was the location of your ApplicationResources file? Was it located in a subpath of /WEB-INF/classes? – Anonymous Human Sep 14 '17 at 17:40
  • No, it was located at src/java/com/projectName/resources – gjman2 Sep 15 '17 at 02:13