10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Basic Requirements of a <strong>Java</strong>Server Faces Application<br />

458<br />

After your project is open in NetBeans IDE, you can change the mapping to the FacesServlet<br />

instance by doing the following:<br />

1. Expand the node of your project in the Projects pane.<br />

2. Expand the Web Pages and WEB-INF nodes that are under the project node.<br />

3. Double-click web.xml.<br />

4. After the web.xml file appears in the editor pane, click Servlets at the top of the editor pane.<br />

<strong>The</strong> FacesServlet configuration appears in the editor pane.<br />

If you prefer to edit the web.xml file directly, perform the following steps to configure a<br />

mapping to the FacesServlet instance:<br />

1. Include a servlet element in the deployment descriptor.<br />

2. Inside the servlet element, include a display-name element and set it to FacesServlet.<br />

3. Also inside the servlet element, add a servlet-name element and set it to FacesServlet.<br />

4. Add a third element, called servlet-class, inside the servlet element and set it to<br />

javax.faces.webapp.FacesServlet. This is the fully-qualified class name of the<br />

FacesServlet class.<br />

5. After the servlet element, add a servlet-mapping element.<br />

6. Inside the servlet-mapping element, add a servlet-name element and set it to<br />

FacesServlet. This must match the name identified by the servlet-name element<br />

described in step 3.<br />

7. Also inside the servlet-mapping element, add a url-pattern element and set it to<br />

whatever mapping you prefer. This will be the path to FacesServlet. Users of the<br />

application will include this path in the URL when they access the application. For the<br />

guessNumber application, the path is /guess/*.<br />

Specifying a Path to an Application Configuration Resource File<br />

As explained in “Application Configuration Resource File” on page 435, an application can have<br />

multiple application configuration resource files. If these files are not located in the directories<br />

that the implementation searches by default or the files are not named faces-config.xml, you<br />

need to specify paths to these files.<br />

To specify these paths using NetBeans IDE, do the following:<br />

1. Expand the node of your project in the Projects pane.<br />

2. Expand the Web Pages and WEB-INF nodes that are under the project node.<br />

3. Double-click web.xml.<br />

4. After the web.xml file appears in the editor pane, click General at the top of the editor pane.<br />

5. Expand the Context Parameters node.<br />

6. Click Add.<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!