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

-
Select OK to Close the Properties dialog box
Page 2 Page 3 Page 4
|
|