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.

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

4. Select the bookstore1 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 bookstore1 project, and select Undeploy and Deploy.<br />

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

http://localhost:8080/bookstore1/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/bookstore1/.<br />

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

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

WAR file and copy it to the<br />

tut-install/javaeetutorial5/examples/web/bookstore1/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/bookstore1/bookstore.<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 set of filter elements that identify servlet filters contained in the application.<br />

<strong>The</strong> Example Servlets<br />

■ A set of filter-mapping elements that identify which servlets will have their requests or<br />

responses filtered by the filters identified by the filter elements. A filter-mapping<br />

element can define more than one servlet mapping and more than one URL pattern for a<br />

particular filter.<br />

■ A set of servlet elements that identify all the servlet instances of the application.<br />

■ A set of servlet-mapping elements that map the servlets to URL patterns. More than one<br />

URL pattern can be defined for a particular servlet.<br />

■ A set of error-page mappings that map exception types to an HTML page, so that the HTML<br />

page opens when an exception of that type is thrown by the application.<br />

Chapter 4 • <strong>Java</strong> ServletTechnology 101

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

Saved successfully!

Ooh no, something went wrong!