Comments in JSF2 Facelets

Facelets/JSF2 pages are well formatted XML (XHTML) documents and not JSP pages, so we cannot use the classic <%- – … – -%> JSP comment format.

Instead, we have to employ use the XML comment syntax <!- – … – ->. The downside is that these comments are sent to the client browser as classic HTML comments.

To avoid this, we have to command the Facelet engine to not include comments in the output stream. We can do this by adding the following code to the web.xml file of our JSF2 web application:


Leave a Reply

Your email address will not be published. Required fields are marked *