Search code examples
jakarta-eefaceletsicefaces

Hide .xhtml source - facelets/icefaces?


I'm new to Icefaces and Facelets both, but I'm using them on a new project. I've got everything working configured and working fine. However, when I visit mywebapp/file.xhtml, the entire facelets template source comes up in my browser. How could I hide this to prevent users from viewing my server-side templates?


Solution

  • Put all templates into WEB-INF/someDirectory/templates.

    Then according to the facelets documentation put this inside your web.xml for all other xhtml files:

    <security-constraint>
        <display-name>Restrict XHTML Documents</display-name>
        <web-resource-collection>
            <web-resource-name>XHTML</web-resource-name>
            <url-pattern>*.xhtml</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <description>Only Let 'developer's access XHTML pages</description>
            <role-name>someone</role-name>
        </auth-constraint>
    </security-constraint>