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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

tut-install/javaeetutorial5/examples/web/<br />

3. Select the guessNumber folder.<br />

4. Select the Open as Main Project check box.<br />

5. Click Open Project.<br />

6. In the Projects tab, right-click the guessNumber project, and select Undeploy and Deploy.<br />

7. To run the application, open the URL http://localhost:8080/guessNumber in a browser.<br />

To build, package, and deploy this example using Ant, follow these steps:<br />

1. Go to tut-install/javaeetutorial5/examples/web/guessNumber/.<br />

2. Type ant.<br />

3. Start the Application Server.<br />

4. Type ant deploy.<br />

5. To run the application, open the URL http://localhost:8080/guessNumber in a browser.<br />

To learn how to configure the example, refer to the deployment descriptor (the web.xml file),<br />

which includes the following configurations:<br />

■ A display-name element that specifies the name that tools use to identify the application.<br />

■ A servlet element that identifies the FacesServlet instance.<br />

■ A servlet-mapping element that maps FacesServlet to a URL pattern.<br />

Mapping the FacesServlet Instance<br />

All <strong>Java</strong>Server Faces applications must include a mapping to the FacesServlet instance in their<br />

deployment descriptors. <strong>The</strong> FacesServlet instance accepts incoming requests, passes them to<br />

the life cycle for processing, and initializes resources. <strong>The</strong> following piece of the guessNumber<br />

example’s deployment descriptor performs the mapping to the FacesServlet instance:<br />

<br />

FacesServlet<br />

FacesServlet<br />

javax.faces.webapp.FacesServlet<br />

<br />

1<br />

<br />

<br />

FacesServlet<br />

/guess/*<br />

<br />

A Simple <strong>Java</strong>Server Faces Application<br />

Chapter 10 • <strong>Java</strong>Server FacesTechnology 287

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

Saved successfully!

Ooh no, something went wrong!