views:

448

answers:

4

Hi,

My imports :

  xmlns:c="http://java.sun.com/jstl/core"
  xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"

My JSTL Code :

  <h:outputLabel value="YESS" >
  <fmt:formatNumber value="0.25" type="percent"></fmt:formatNumber>


HTML generated code:

  <label>YESS</label>
  <fmt:formatNumber value="0.25" type="percent"></fmt:formatNumber>

The generated code show that the JSTL core is translate in HTML.
But the JSTL "fmt" is not translate in HTML.





More information:

    <fmt:ErrorInThisFunctionName value="0.25" type="percent" />    ===> generate an error
  • I work on Tomcat 6
A: 

suggestion:

  • check your TLD file.
  • check your header (DTD, attributes) in your web.xml
Pierre
+1  A: 

What Pierre said, and also,

Try xmlns:fmt="http://java.sun.com/jstl/fmt"

Check web.xml for

<web-app version="2.4"
                 xmlns="http://java.sun.com/xml/ns/j2ee"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;
lucas
+1  A: 

If you are using the normal JSP syntax and not the XML-based syntax try using

<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
Mr. Will
A: 
xmlns:c="http://java.sun.com/jstl/core"
xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"

The URI for core taglib is invalid. It should be http://java.sun.com/jsp/jstl/core as per its TLD, with /jsp. The URI for format taglib is perfectly fine as per its TLD.

Does the core taglib work in any way? If it doesn't work as well, then it simply means that JSTL is not installed at all. Tomcat does not ship with JSTL by default. You need to download jstl-1.2.jar and put it in /WEB-INF/lib of your webapp. That's all. Do not extract the JAR file and put its loose contents (TLD files and so on) in the classpath as some poor tutorials suggests. It will only get worse. If you already did so, you should cleanup. Only putting the JSTL JAR in classpath is enough.

BalusC