There are two distribution methods for the Struts framework, source and binary. The source distribution gives you more control over the build package environment. However, this method is not for beginners. Unless you have a specific need (e.g., you need to insert a modified class file into the build), you should stick with the binary distribution. This section presents both methods. B.1.1 Building Struts from the Source DistributionYou can obtain the source packages of Struts and the rest of the Jakarta projects from http://jakarta.apache.org/site/sourceindex.html. Several different versions are usually available, so be sure to get the one that's appropriate for your needs. There is always a nightly build of Struts that includes the latest changes and fixes. In most situations, you'll want to go with the nightly build, but be aware that it may also include new bugs.
Once you have downloaded the appropriate version, extract the contents into a directory. The directory doesn't have to be empty, but it's easier if it is. The Struts source distribution file unpacks everything into a subdirectory called jakarta-struts. Before you can build the source files, you will also need to download several prerequisite software packages (if they're not already installed in your environment). The following list describes the required software:
You will also need to download the third-party packages listed in Table B-1 and extract the JAR files included with the packages. Each package has both a source and binary distribution available. Unless you are a true masochist, you should download the binary distributions of these packages.
Extract the binary distributions of each of these packages and put the JAR files somewhere that you can easily reference them, as will need to in the next step. Each package is extracted into its own subdirectory. You can leave the JAR files there for easier reference. The next step is to create a build.properties file that specifies environmental dependencies such as the location of the third-party JARs extracted in the previous step. The Struts source distribution provides a build.properties.sample file in the top-level source distribution directory. Open this file and rename it build.properties. You need to customize this file for your particular environment. The file paths are relative to the location of the properties file. For example, to reference the Commons BeanUtils JAR file that is located in a directory called lib one level up, you would need to change the properties file to look like this: # The JAR file containing version 1.0 (or later) of the Beanutils package # from the Jakarta Commons project. commons-beanutils.jar=../lib/commons-beanutils-1.3/commons-beanutils.jar Once you have all of the file paths set in the build.properties file, you are ready to turn the Struts source files into Struts binary files. Make sure Ant is installed and configured correctly, and make sure you downloaded the xalan.jar file and placed it in the <ANT_HOME>/lib directory (this is needed so that an Ant task can process the XML documentation files). You will need to be able to execute Ant from the command line in the top-level source directory. Once you've completed these steps, go to the directory where the build.properties file is located and type: ant dist Messages will be spewed out in the console. When they finally stop, they should show that the build was successful, as in Figure B-1. Figure B-1. A success message is printed when completeIf the build is unsuccessful, you will get a failed message, usually with enough information to determine the cause. For example, if you forget to put the xalan.jar in the <ANT_HOME>/lib directory, the output will look similar to that in Figure B-2. Figure B-2. A stack trace is usually included in failed buildsAssuming that the build was successful, the Struts binaries and dependent files are copied to the dist directory underneath the top-level source distribution directory. B.1.2 Installing the Binary DistributionDownload the binary distribution and unpack it into a directory. The files are in a subdirectory called jakarta-struts within the distribution. As with the source distribution, you can download either a ZIP file or a compressed TAR file. You can obtain the binary distribution from http://jakarta.apache.org/site/binindex.html.
The following steps need to be performed for a Struts application to work properly. Any necessary container-dependent modifications to these steps are discussed in the sections for the individual containers later in this appendix.
That's really all there is to installing the Struts framework. You still have to build the necessary JSP pages and other framework components, such as Action and ActionForm classes, but this is what is required to get the environment running. It's highly recommended that you play around with the example applications that are distributed with Struts. They are complete web applications, packaged as WAR files that you can copy to the container's webapps directory. You have the option of using one of many different containers to run the Struts framework. In many cases, the steps just described should be followed exactly. However, not all containers are created equal, and some require modifications to the steps listed. The necessary modifications, if any, are described below. |