Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF faces config file outside WEB-INF?

When creating multiple faces config files, it is correct to have the faces-config.xml outside of WEB-INF? The JSF spec does not seem to be very clear about this (Section 10.1.3)

If yes, how should this faces-config.xml be declared in web.xml? the paths generated by IDE's (like Eclipse/JDev) generally use something like:

<context-param>
    <param-name>javax.faces.CONFIG_FILES</param-name>
    <param-value>/WEB-INF/faces-config1.xml</param-value>
</context-param>

Now, if my faces-config.xml is outside WEB-INF -- is it correct to declare the param-value as something like "/WebContent/WEB-INF/faces-config2.xml"?

like image 334
Debajit Avatar asked Sep 02 '09 01:09

Debajit


People also ask

Where do I put faces-config xml?

xml file is found in the META-INF directory of a jar in the application's classpath. A filename ending in . faces-config. xml is found in the META-INF directory of a jar in the application's classpath.

What is faces-config xml in JSF?

Each JSF application needs a faces-config. xml configuration file. It describes the application properties, such as navigation rules between the JSF pages, default bean instances, default values of some variables, message bundles, and so on.

What is Web xml JSF?

xml is the deployment descriptor file and it is part of the servlet standard for web applications. It is used to determine how URLs map to servlets, which URLs require authentication, and other information. This file resides in the app's WAR under the WEB-INF/ directory.


2 Answers

It is possible, but not recommended. The reason you put configuration files under WEB-INF is that the server knows not to serve these files - you have your code, database configuration and other sensitive stuff there.

You cannot use "/WebContent/WEB-INF/faces-config2.xml" - AFAIK "WebContent" is eclipse specific. have the config files names to be absolute inside the WAR. It means that they will always begin with "/WEB-INF/".

like image 56
David Rabinowitz Avatar answered Oct 27 '22 10:10

David Rabinowitz


As mentioned in David's answer, it's not recommended to put the config files outside of the WEB-INF directory. However, if you're looking for ways to organise your project, you might try creating a new subdirectory under WEB-INF.

For example, when I'm dealing with lots of faces-config files, I'll create a directory /WEB-INF/config and put the faces-config files in there.

like image 22
harto Avatar answered Oct 27 '22 09:10

harto