After these questions:
- https://stackoverflow.com/questions/8589315/jsf2-dynamic-template
- Dynamic ui:include
- How can I retrieve an object on @WindowScoped?
- How can I check if an object stored with @WindowScoped is stored correctly?
- ICE Faces and error in creation of a bean in WindowScoped
that I wrote all to resolve a "stupid" issue for the JSF2 framework, the fact that I can't link directly to a page stored in a /WEB-INF
subfolder. After that I did some research on Google and Stackoverflow I would know a thing: How do I structure a JSF2 web project?
In particular, where exactly do I put the XHTML pages?
Files in
/WEB-INF
folder are indeed not publicly accessible by enduser. So you cannot have something likehttp://localhost:8080/contextname/WEB-INF/some.xhtml
. That would be a potential security hole as the enduser would be able to view among others/WEB-INF/web.xml
and so on.You can however use the
/WEB-INF
folder to put master template files, include files and tag files in. For example, the following template clientpage.xhtml
which is placed outside/WEB-INF
and is accessible byhttp://localhost:8080/contextname/page.xhtml
:The advantage of placing master templates and include files in
/WEB-INF
is that the enduser won't be able to open them directly by entering/guessing its URL in the browser addres bar. The normal pages and template clients which are intented to be accessed directly must not be placed in/WEB-INF
folder.By the way, the composite component files are in turn also not supposed to be publicly accessible, however they are by specification required to be placed in
/resources
folder which is by default publicly accesible. If you make sure that you access all resources using the therefor provided components so that they are never accessed by/resources
in URL (but instead by/javax.faces.resource
), then you can add the following constraint toweb.xml
to block all public access to the/resources
folder: