Search code examples
jspjsf-2facelets

How to use Facelets' ui:repeat tag in JSP?


I am using JSF 2.0 on JSP 2.1. Is there any possibility to use Facelets' <ui:repeat> tag in JSP files?

I have imported the Facelets taglib in JSP as

<%@ taglib uri="http://java.sun.com/jsf/facelets" prefix="ui"%>

But it is not identifying the taglib ui.taglib.xml that comes with jsf-impl.jar and gives an error in render time as

org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsf/facelets cannot be resolved in either web.xml or the jar files deployed with this application

But this <ui:repeat> tag works fine in my Facelets files.


Solution

  • That's not possible. Facelets is a distinct view technology and technically the successor of JSP. You cannot mix them nor use Facelets tags in JSP files. For JSF2 it's strongly recommended to use Facelets instead of JSP as it's far superior over JSP.

    For JSP, your best bet is using JSTL <c:forEach> instead. It has similar syntax, only the items attribute is been used instead of value. Or if it needs to be a render-time tag like <ui:repeat> instead of a build-time tag, then consider looking at Tomahawk's <t:dataList>.