background image

Application Configuration Resource File

<< Extension Mapping | Specifying Where State Is Saved >>
<< Extension Mapping | Specifying Where State Is Saved >>

Application Configuration Resource File

3. Double-click web.xml.
4. After the web.xml file appears in the editor pane, click Servlets at the top of the editor pane.
The FacesServlet configuration appears in the editor pane.
If you prefer to edit the web.xml file directly, perform the following steps to configure a
mapping to the FacesServlet instance:
1. Include a servlet element in the deployment descriptor.
2. Inside the servlet element, include a display-name element and set it to FacesServlet.
3. Also inside the servlet element, add a servlet-name element and set it to FacesServlet.
4. Add a third element, called servlet-class, inside the servlet element and set it to
javax.faces.webapp.FacesServlet
. This is the fully-qualified class name of the
FacesServlet
class.
5. After the servlet element, add a servlet-mapping element.
6. Inside the servlet-mapping element, add a servlet-name element and set it to
FacesServlet
. This must match the name identified by the servlet-name element
described in step 3.
7. Also inside the servlet-mapping element, add a url-pattern element and set it to
whatever mapping you prefer. This will be the path to FacesServlet. Users of the
application will include this path in the URL when they access the application. For the
guessNumber
application, the path is /guess/*.
Specifying a Path to an Application Configuration Resource File
As explained in
"Application Configuration Resource File" on page 437
, an application can have
multiple application configuration resource files. If these files are not located in the directories
that the implementation searches by default or the files are not named faces-config.xml, you
need to specify paths to these files.
To specify these paths using NetBeans IDE, do the following:
1. Expand the node of your project in the Projects pane.
2. Expand the Web Pages and WEB-INF nodes that are under the project node.
3. Double-click web.xml.
4. After the web.xml file appears in the editor pane, click General at the top of the editor pane.
5. Expand the Context Parameters node.
6. Click Add.
7. In the Add Context Parameter dialog:
a. Enter javax.faces.CONFIG_FILES in the Param Name field.
b. Enter the path to your configuration file in the Param Value field.
c. Click OK.
Basic Requirements of a JavaServer Faces Application
Chapter 14 · Configuring JavaServer Faces Applications
461