2

When I configure the FacesServlet in my web.xml, where does it search for *.xhtml facelets? Only in App-Root?

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
Gerrit
  • 1,969
  • 5
  • 28
  • 48

3 Answers3

1

I don't understand your question. But a try to an answer: All files in your web directory (and subdirs) that have the xhtml extension will be handeled as facelets.

roel
  • 1,957
  • 3
  • 23
  • 38
  • Okay, thanks! How I get this question? When I store a facelet with .xhtml extension to webroot and the standard /faces/*-mapping, then I can access my facelet on theses two ways: /welcome.xhtml (Without Faces technology as standard xhtml) and via /faces/welcome.xhtml (as facelet). I don't want the first access point so I tried to store my facelet in /WEB-INF/welcome.xhtml but then I get the error that the faces servlet don't find the facelet-file. What should I do to restrict the access only vie faces servlet? – Gerrit Nov 22 '12 at 11:35
1

They're by default scanned in the web root folder of the WAR and in the /META-INF/resources folder of all JARs included in the /WEB-INF/lib of the WAR. You can control this scanning algorithm with a custom ResourceResolver. Here's a (relatively foolish) example which scans for an additional location on local disk file system as well when nothing is found in WAR (nor in JARs in its /WEB-INF/lib):

public class MyResourceResolver extends ResourceResolver {

    private ResourceResolver parent;

    public MyResourceResolver(ResourceResolver parent) {
        this.parent = parent;
    }

    @Override
    public URL resolveUrl(String path) {
        URL url = parent.resolveUrl(path); // Resolves from WAR.

        if (url == null) {
            url = new File("/some/folder", path).toURI().toURL();
        }

        return url;
    }

}

As to placing Facelets files in /WEB-INF folder, you should only put Facelets files in there which are not supposed to be publicly accessible, such as template files, tag files, include files, etc. Files which are supposed to be publicly accessible should not be placed in there, such as template clients (the top level views).

See also:

Community
  • 1
  • 1
BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
0

It will depends of theses parameters in web.xml :

<context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
</context-param>

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jspx</url-pattern>
</servlet-mapping>
Alexandre Lavoie
  • 8,504
  • 3
  • 26
  • 68