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.

<strong>The</strong> Example JSP Pages<br />

200<br />

To deploy and run the application using NetBeans IDE, follow these steps:<br />

1. Perform all the operations described in “Accessing Databases from Web Applications” on<br />

page 97.<br />

2. In NetBeans IDE, select File→Open Project.<br />

3. In the Open Project dialog, navigate to:<br />

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

4. Select the bookstore4 folder.<br />

5. Select the Open as Main Project check box and the Open Required Projects check box.<br />

6. Click Open Project.<br />

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

8. To run the application, open the bookstore URL<br />

http://localhost:8080/bookstore4/books/bookstore.<br />

To deploy and run the application using Ant, follow these steps:<br />

1. In a terminal window, go to tut-install/javaeetutorial5/examples/web/bookstore4/.<br />

2. Type ant. This command will spawn any necessary compilations, copy files to the<br />

tut-install/javaeetutorial5/examples/web/bookstore4/build/ directory, and create a<br />

WAR file and copy it to the<br />

tut-install/javaeetutorial5/examples/web/bookstore4/dist/ directory.<br />

3. Start the Application Server.<br />

4. Perform all the operations described in “Creating a Data Source in the Application Server”<br />

on page 98.<br />

5. To deploy the example, type ant deploy. <strong>The</strong> deploy target outputs a URL for running the<br />

application. Ignore this URL, and instead use the one shown in the next step.<br />

6. To run the application, open the bookstore URL<br />

http://localhost:8080/bookstore4/books/bookstore.<br />

To learn how to configure the example, refer to the web.xml file, which includes the following<br />

configurations:<br />

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

■ A context-param element that specifies the JSTL resource bundle base name.<br />

■ A set of servlet elements that identify the application’s JSP files.<br />

■ A set of servlet-mapping elements that define the aliases to the JSP files.<br />

■ Nested inside a jsp-config element are two jsp-property-group elements, which define<br />

the preludes and coda to be included in each page. See “Setting <strong>Java</strong>Beans Component<br />

Properties” on page 168 for more information.<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!