6.2 Installation

"Would you tell me, please, which way I ought to go from here?"

"That depends a good deal on where you want to get to."

"I don't much care where"

"Then it doesn't much matter which way you go."

"so long as I get somewhere."

"Oh, you're sure to do that, if only you walk long enough."

Prerequisite Software

The framework's binary distribution needs three other software packages installed to operate. You may already have these installed on your system. To build the framework from source you may need to acquire and install several others. The complete list is as follows:

  • Java Development Kit - You must download and install a Java Development Kit (version 1.4 or later) implementation for your operating system platform. A good starting point for locating Java Development Kit distributions is http://java.sun.com/j2se. To build the framework, Java 1.4.2 (the latest production JDK) is suggested and required if you use our Maven build system.
  • Servlet Container - You must download and install a servlet container that is compatible with the Servlet API Specification, version 2.3 or later, and the JavaServer Pages (JSP) Specification, version 1.2 or later. One popular choice is to download Apache's Tomcat , but any compliant container should work well with the framework.
  • Maven Build System - (optional) If you are building the framework from the source distribution, you must download and install the Apache Maven 2 build system (2.0.4 or later).

Install a Library Distribution

First, download a binary distribution of Struts by following the instructions here, Then, make sure you have downloaded and installed the prerequisite software packages described above.

Unpack the Library distribution into a convenient directory. (If you are building from the source distribution, the result of the build will already be an unpacked binary distribution for you). The distribution consists of the following contents:

  • lib/*.jar - The struts-*.jars contains Java classes distributed by Apache Struts. The other JAR files contain packages from other projects that are imported by the framework. When you launch a your application, these JARs need to be available to your application, usually by copying them to the application's WEB-INF/lib directory.
    WARNING - If you are going to be hosting multiple applications on the same servlet container, you will be tempted to place the struts-core.jar file into the shared repository supported by your container. Be advised that this may cause ClassNotFoundException problems unless all of your application classes are stored in the shared repository.

To use Struts Library in your own application, you will need to follow these steps:

  • Copy the lib/*.jar files from the Library distribution into the WEB-INF/lib directory of your web application.
  • Modify the WEB-INF/web.xml file for your web application to include a <servlet> element to define the controller servlet, and a <servlet-mapping> element to establish which request URIs are mapped to this servlet. Use the WEB-INF/web.xml file from the Struts Mailreader application for a detailed example of the required syntax.
  • Create a file WEB-INF/struts-config.xml that defines the action mappings and other characteristics of your specific application. You can use the struts-config.xml file from the Struts Blank application for examples of the required syntax.
  • At the top of each JSP page that will use JSP tags, add line(s) declaring the JSP tag libraries used on this particular page, like this:
                    <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
                    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
                    <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
  • When compiling the Java classes that comprise your application, be sure to include the JAR files (copied earlier) on the CLASSPATH that is submitted to the compiler.

Installing The Framework With Your Servlet Container

For most containers, you need only to:

  • Copy the WAR files in your /webapps directory to your containers webapps directory.
  • In some cases, you may need to restart your container if it is running.

Running Applications Under A Security Manager

Many application servers execute web applications under the control of a Java security manager, with restricted permissions on what classes in the web application can do. If you utilize form beans with mapped properties, you may encounter security exceptions unless you add the following permission to the set of permissions granted to your application's codebase:

                    permission java.lang.RuntimePermission

Consult the documentation on your application server for more information about how to configure additional security manager permissions.

Installing on Various Containers