The Java EE 5 Tutorial

Steps in the Development Process

Developing a simple JavaServer Faces application usually requires these tasks:

The example used in this section is the guessNumber application, located in the tut-install/javaeetutorial5/examples/web/ directory. It asks you to guess a number between 0 and 10, inclusive. The second page tells you whether you guessed correctly. The example also checks the validity of your input. The system log prints Duke’s number. Figure 10–2 shows what the first page looks like.

Figure 10–2 The greeting.jsp Page of the guessNumber Application

Screen capture of Duke asking you to guess a number between
1 and 10, with a text field and a Submit button.

The source for the guessNumber application is located in the tut-install/javaeetutorial5/examples/web/guessNumber/ directory created when you unzip the tutorial bundle (see Chapter 2, Using the Tutorial Examples).

    To build, package, deploy, and run this example using NetBeans IDE, follow these steps:

  1. In NetBeans IDE, select File->Open Project.

  2. In the Open Project dialog, navigate to:

  3. Select the guessNumber folder.

  4. Select the Open as Main Project check box.

  5. Click Open Project.

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

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

    To build, package, and deploy this example using Ant, follow these steps:

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

  2. Type ant.

  3. Start the Application Server.

  4. Type ant deploy.

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

To learn how to configure the example, refer to the deployment descriptor (the web.xml file), which includes the following configurations: