Having an issue rendering jstl tags from within a facelets ui:composition
My current xmlns imports are:
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
When I deploy it renders the text as
<c:forEach> ...
within the html output.
Am I missing a dependency? Is the import incorrect? Is using jstl tags within facelets even possible?
Thanks a bunch!
The given XML namespaces (note: that are not "xmlns imports") are correct for JSF 2.x. However, in Facelets 1.x, which is to be used standalone in JSF 1.x projects, the XML namespace for JSTL is different, it should not contain the /jsp
path.
xmlns:c="http://java.sun.com/jstl/core"
But if you're actually already using JSF 2.x (in future JSF 2.x questions please mention and tag accordingly), then you're probably using a servletcontainer which doesn't ship with JSTL included, such as Apache Tomcat. You'd need to download JSTL separately and drop it in /WEB-INF/lib
folder. In that case the xmlns:c="http://java.sun.com/jsp/jstl/core"
should work.
Unrelated to the concrete question, using JSTL in Facelets is definitely possible. You should only make sure that you really understand the lifecycle of tag handlers like JSTL in JSF. See also JSTL in JSF2 Facelets... makes sense? You could alternatively also just use Facelets' own <ui:repeat>
tag instead of the <c:forEach>
.