Section 2: Installing & Configuring Struts

Installing Struts; Setting Up Struts Applications

2.1 Downloading & Configuring Struts 2.2 Testing Struts
2.3 Setting Up Struts Applications 2.4 Accessing Struts Documentation
2.5 Adding Struts to an Existing Web Application
Struts Tutorial Table of Contents More Info

This section shows you how to download and set up the Apache Struts software.

2.1 Downloading and Configuring Struts

  1. Download the Struts zip file.
    Start at, or follow the link from I'm using Struts 1.1 in this tutorial.
  2. Unzip into a directory of your choice.
    For example, unzip into C:\jakarta-struts-1.1. Throughout the rest of this tutorial, I'll refer to this location as struts_install_dir.
  3. Update your CLASSPATH.
    Add struts_install_dir/lib/struts.jar to the CLASSPATH used by your compiler or IDE (not your server). Here are three possible ways of setting it:
  4. Install an XML parser.
    If you have JDK 1.4 or Apache Tomcat, this step is not necessary, since they already come with an XML parser. But, if you use JDK 1.2 or 1.3 with another server, you might need to obtain the XML parsing libraries. Here are two good sources:

2.2 Testing Struts

  1. Install struts-blank.war.
    Install the Web application from struts_install_dir/webapps/struts-blank.war on your server. For example, with Apache Tomcat, copy struts_install_dir/webapps/struts-blank.war to tomcat_install_dir/webapps/.
  2. Start or restart the server.
    Most servers only recognize new Web apps when the server is started.
  3. Access http://localhost/struts-blank/.
    This URL assumes you are running the server on your desktop and are using port 80. In general, access http://hostname:port/struts-blank/. You should see something like the following.

2.3 Setting Up Struts Applications

To make your own Struts application, you need to create a Web application that has the appropriate JAR files, TLD files, and web.xml entries. You almost always do this by starting with the struts-blank application and modifying it. You have three options for doing this:

2.4 Accessing Struts Documentation

You probably already have bookmarked the APIs for standard Java, servlets, and JSP. But you will also want to frequently refer to the Apache Struts documentation. You can do this two ways:

2.5 Adding Struts to an Existing Web Application

By far the easiest way to develop a Struts application is to start with struts-blank, rename it, and work from there. If that approach is an option for you, do it that way and skip this section. However, if you already have an existing Web application and want to add Struts capabilities to it, starting with struts-blank won't work. Adding Struts capabilities to existing Web apps is a huge pain in the neck, and will proably require several attempts to get it right. Here is a quick summary:

Next section: Processing Requests with Action Objects

More Information

Servlet, JSP, and Struts Short Courses
Personally developed and taught by the author of Core Servlets & JSP, More Servlets & JSP, and this Jakarta Struts tutorial.
  • Programming with Servlet & JSP Technology. Fast-paced, hands-on course for developers who know Java but have little or no experience with servlets and JSP. Offered Nov 30-Dec 3 in Columbia, MD.
  • Advanced Servlet, JSP, & Struts Programming. Advanced hands-on course for developers with significant previous experience with servlets and JSP. Offered Dec 7-10 in Columbia, MD.
  • Applying Apache Struts. Advanced Struts-only course for those with significant previous JSP and servlet experience.
  • On-site JSP, Servlet, Struts, & JSF Training Courses. Customizable courses taught by Marty at your organization. Choose any combination of topics from Marty's Java, JSP, servlet, Struts, and JSF courses.
Contact Marty
Send email to [email protected] to report errors and omissions in this writeup or inquire about JSP/servlet/Struts training courses.
  • Apache Struts home page.
  • Apache Struts documentation.
  • JSP and servlet programming resources.
  • Servlet 2.3 and JSP 1.2 API.
  • Servlet 2.4 API.
  • JSP 2.0 API.
  • JSP, servlet, and Struts training and consulting
Apache Struts Books
  • Struts in Action: Building Web Applications with the Leading Java Framework.
  • Programming Jakarta Struts.
  • Professional Jakarta Struts.
Servlet & JSP Books
  • Core Servlets and JavaServer Pages, Second Edition.
  • Free online version of the First Edition of Core Servlets and JavaServer Pages. In PDF.
  • More Servlets and JavaServer Pages.