Chapter 3: Getting Started with Struts

 < Day Day Up > 



In this chapter, we begin our Jakarta Struts coverage. First, we explain the steps that you must perform when installing and configuring a Struts application. Then, we create a sample application that displays the core components of a working Struts application. We conclude this chapter by walking through our sample application.

The goal of this chapter is to provide you with a quick introduction to the components of a Struts application. At the end of this chapter, you should have a pretty good understanding of the architecture of a basic Struts application.

Obtaining and Installing the Jakarta Struts Archive

Before you can get started with your Struts development, you need to prepare your environment. This begins with the acquisition of the latest release of the Struts project. For our examples, we will be using Struts 1.1, which you can find at http://jakarta.apache.org. You need to locate and download the binary distribution for your operating system.

Once you have the 1.1 Struts release, complete the following steps to prepare for the remainder of the text. You have to complete these steps for each Struts Web application that you intend to deploy.

  1. Uncompress the Struts archive to your local disk.

  2. Create a new Web application, using the directory structure described in Chapter 1, "Introducing the Jakarta-Struts Project and Its Supporting Components" (be sure to substitute the name of your Web application for the value wroxapp). In the case of this example, the name of our Web application is ch03app.

  3. Copy the all of the JAR files, extracted from the lib directory, into the <CATALINA_HOME>/webapps/ch03app/WEB-INF/lib directory.

  4. Create an empty web.xml file and copy it to the <CATALINA_HOME>/webapps/ch03app/WEB-INF/ directory. An example web.xml file is shown in the following code snippet.

     <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app   PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application   2.3//EN"   "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd"> <web-app> </web-app> 

  5. Create an empty strut-config.xml file and copy it to the <CATALINA_HOME>/webapps/ch03app/WEB-INF/ directory. The struts-config.xml file is the deployment descriptor for all Struts applications. It is the file that glues all of the MVC components together. Its normal location is in the <CATALINA_HOME>/webapps/webappname/WEB-INF/ directory. We use this file extensively throughout the remainder of this book. An empty struts-config.xml file is shown here:

     <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE struts-config   PUBLIC "-//Apache Software Foundation//DTD Struts   Configuration 1.1//EN"   "http://jakarta.apache.org/struts/dtds/struts- config_1_1.dtd"> <struts-config> </struts-config> 

At this point, you have all of the necessary components to build the simplest of Struts applications. As you begin the design and development of our example Struts application, you will need to install and configure further Struts components as necessary. The next section of this chapter takes you through the steps for developing our example application.



 < Day Day Up > 



Professional Jakarta Struts
Professional Jakarta Struts (Programmer to Programmer)
ISBN: 0764544373
EAN: 2147483647
Year: 2003
Pages: 183

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net