background image

Deploy and Run the Application using Ant

<< The Example Servlets | Servlet Life Cycle >>
<< The Example Servlets | Servlet Life Cycle >>

Deploy and Run the Application using Ant

tut-install/javaeetutorial5/examples/web/
4. Select the bookstore1 folder.
5. Select the Open as Main Project check box and the Open Required Projects check box.
6. Click Open Project Folder.
7. In the Projects tab, right-click the bookstore1 project, and select Deploy Project.
8. To run the application, open the bookstore URL
http://localhost:8080/bookstore1/bookstore
.
To deploy and run the application using Ant, follow these steps:
1. In a terminal window, go to tut-install/javaeetutorial5/examples/web/bookstore1/.
2. Type ant. This command will spawn any necessary compilations, copy files to the
tut-install/javaeetutorial5/examples/web/bookstore1/build/ directory, and create a
WAR file and copy it to the
tut-install/javaeetutorial5/examples/web/bookstore1/dist/ directory.
3. Start the Application Server.
4. Perform all the operations described in
"Creating a Data Source in the Application Server"
on page 98
.
5. To deploy the example, type ant deploy. The deploy target outputs a URL for running the
application. Ignore this URL, and instead use the one shown in the next step.
6. To run the application, open the bookstore URL
http://localhost:8080/bookstore1/bookstore
.
To learn how to configure the example, refer to the deployment descriptor (the web.xml file),
which includes the following configurations:
A display-name element that specifies the name that tools use to identify the application.
A set of filter elements that identify servlet filters contained in the application.
A set of filter-mapping elements that identify which servlets will have their requests or
responses filtered by the filters identified by the filter elements. A filter-mapping
element can define more than one servlet mapping and more than one URL pattern for a
particular filter.
A set of servlet elements that identify all the servlet instances of the application.
A set of servlet-mapping elements that map the servlets to URL patterns. More than one
URL pattern can be defined for a particular servlet.
A set of error-page mappings that map exception types to an HTML page, so that the HTML
page opens when an exception of that type is thrown by the application.
The Example Servlets
Chapter 4 · Java Servlet Technology
101