The example application described below is a basic Sturts 1 application. The basic flow of the application is a simple form page which goes through a Struts action and re-displays the contents of the form. The example application illistrates using the blank application provided by the Apache group and expanding it contain two JSPs and one action.

The following is a tutorial on how to create a basic Struts 1 Application using Eclipse. The tutorial assumes that you have Java 1.4 or better installed and you have a basic understanding of using Eclipse. This example uses Tomcat 5.0 as the application container.

  1. Download Struts 1.3.5 (or a later release of Struts 1) and extract it to C:\struts-1.3.5
  2. Setup Tomcat
    1. Download Tomcat 5.0 (Windows Install Version) and Install it to C:\Tomcat5.0 (For more information, see the Apache Tomcat website.)
    2. Start the Tomcat service
      1. Go to Start menu => All Programs => Apache Tomcat 5.0
      2. Select Monitor Tomcat
      3. From your tool bar double click the tomcat icon
        Tomcat Shell Icon on Task bar
      4. From the Apache Tomcat properties dialog box, Click Start. Click OK after the service has finished starting.
        Tomcat Properties Dialog Box
    3. Using a web browser, go to http://localhost:8080. You should see the Tomcat default home page.
  3. Open Eclipse and create a new project
    1. Double click C:\Eclipse\eclipse.exe
    2. In Eclipse, Go to File => New => Project
    3. Select Java Project, Click Next, Give the project a name, and Click Finish.
  4. Setup basic file structure of the project
    1. Right click the project name and select New => Folder. Name it "src." This is the folder that contains all of the source files.
      Creating New Folders in Eclipse
    2. Create two more folders, one called "ant" and another called "WebRoot." The first will contain Ant build scripts for copying the Struts application to the Tomcat webapps directory. The second will be the root of the web application.
  5. Get blank Struts application from Struts 1.3.5
    1. Navigate to C:\struts-1.3.5\apps using Explorer
    2. Right click on struts-blank-1.3.5.war, and select copy.
    3. Paste the struts-blank-1.3.5.war into your newly created Eclipse project under WebRoot
      1. Extract all of the contents of the war file to that folder.
      2. Delete the struts-blank-1.3.5.war file
      3. Delete the META-INF folder
    4. The WebRoot folder should now contain the following:
      1. WEB-INF: Standard directory for a J2EE application
      2. pages: Directory for all JSP pages in this application
      3. index.jsp: Default page for the application
  6. Setup source folders in Eclipse
    1. Bring the Eclipse window back up
    2. Right click the project name and select Properties
    3. Select the Java Build Path => Source
    4. Select Add Folder
      1. From the Source Folder Selection dialog box, select src then OK
        Source Folder Selection in Eclipse
    5. Select Yes from the Source Folder Added dialog box
      Source Folder Added in Eclipse
    6. Change the default output folder
      1. Select Browse
      2. From the file tree, select classes under WebRoot/WEB-INF
      3. Select OK
        Folder Selection in Eclipse
        Properties for Application in Eclipse
      4. Select OK to Close the Properties dialog box
Page 2 Page 3 Page 4