Struts 1 - The Struts Framework Project - Installation - Tomcat with Apache

##### Struts 1

- Welcome
- Learning
- Roadmap
- Releases

##### Documentation

- User Guide
- FAQs and HOWTOs
- Release Notes
- Javadoc
- DTDDoc

##### Support

- User Mailing List
- Issue Tracker (JIRA)
- Wiki Pages

##### Components

- Struts Apps
- Struts EL
- Struts Extras
- Struts Faces
- Struts Scripting
- Struts Taglib
- Struts Tiles

##### Project Documentation

- Project Information
- Project Reports

## 6.2 Installation

### Installing Struts with your servlet container

#### Tomcat 3.2.1 With Apache

Note that the instructions for Tomcat 4 will be different than those for Tomcat 3, but the Tomcat 4.0 web connector is still under development. Versions of Tomcat prior to 3.2.1 are not recommend for use with Struts.

- These instructions assume you have successfully integrated Tomcat with Apache according to the Tomcat documentation.
- Copy "struts-documentation.war" and "struts-example.war" to your $TOMCAT_HOME/webapps directory
- Restart Tomcat if it is already running
- Tomcat will generate a file "$TOMCAT_HOME/conf/tomcat-apache.conf" that will be used by Apache. This file is regenerated every time you start Tomcat, so copy this file to a safe place (such as your Apache configuration directory; on Unix systems this is usually `/usr/local/apache/conf` .
- If you are running Tomcat 3.1, Tomcat will not have generated the entries for your new applications. Add the following lines to the `tomcat-apache.conf` file that you have saved, replacing $TOMCAT_HOME with the path to your Tomcat home directory:

                        Alias /struts-documentation
                        "$TOMCAT_HOME/webapps/struts-documentation
                        <Directory "$TOMCAT_HOME/webapps/struts-documentation>
                        Options Indexes FollowSymLinks
                        </Directory>
                        ApJServMount /struts-documentation/servlet
                        /struts-documentation
                        <Location "/struts-documentation/WEB-INF/">
                        AllowOverride None
                        deny from all
                        </Location>
                        Alias /struts-example
                        "$TOMCAT_HOME/webapps/struts-example"
                        <Directory "$TOMCAT_HOME/webapps/struts-example>
                        Options Indexes FollowSymLinks
                        </Directory>
                        ApJServMount /struts-example/servlet /struts-example
                        <Location "/struts-example/WEB-INF/">
                        AllowOverride None
                        deny from all
                        </Location>

- The generated file above does not know anything about extension mappings defined in a web.xml file, so the "*.do" URIs that go to the controller servlet will not be recognized. To fix this, add the following line to the saved version of "tomcat-apache.conf", after the corresponding line for the .jsp extension:
  `AddHandler jserv-servlet .do`
- Ensure that the saved version of "tomcat-apache.conf" is referenced in your Apache "httpd.conf" configuration file. A typical use would have the following line at the bottom of "httpd.conf":
  `Include /usr/local/apache/conf/tomcat-apache.conf`
- In order to recognize "index.jsp" as a default page for web applications, search in your "httpd.conf" for a "DirectoryIndex" directive. If you have one, add "index.jsp" to the end of the list, so that it might look like this:
  `DirectoryIndex index.html index.jsp`
  If you do not have such an entry, add one like this:
  `DirectoryIndex index.jsp`
- Restart Apache to make it aware of the new applications. You should now be able to access the applications from a browser like this:
  `http://localhost/struts-documentation
  http://localhost/struts-example`

Back to Installation