Struts Hello World Example

This is an example of how you can setup a java web project using struts 1 framework
In this example, you will use :

tomcat_logo Tomcat Server 7
Java_Logo Java SDK
struts Apache Struts
project-logo Apache Ant

Note : Apache Struts 1 has reached its EOL (End of life) at 2013-04-05

1. Create a java web application. Simply create a folder structure like in the below example

2. Java Web Application require you to have a web.xml. So create one inside \webapp\WEB-INF folder

3. Download struts from
Most of the time you only require the binary. So you can just click on the link for binary. (approximate 44.5Mb file size)

4. Unzip and look for the lib folder

5. Copy all jar files inside lib folder to /webapp/WEB-INF/lib

6. Create a
Create a and place in \src\com\justexample\struts\form

7. Create a
Create a and place in \src\com\justexample\struts\action

8. Create a HelloWorld.jsp.
Create a HelloWorld.jsp inside /webapp folder.

9. Configure Struts
To tell the struts about your class. Create a struts-config.xml inside /webapp/WEB-INF/

10. Change web.xml
Change web.xml as per following. In this example, ActionServlet will map to *.do (anything end with .do)
The servlet then read configuration from struts-config.xml.

11. Install Tomcat
Download tomcat. Unzip it to c:\tomcat

12. Create a build.xml
Create a build.xml file and place it in the folder containing src and webapp.
Note : If you do not have ant, try follow the Install Ant in Windows to install one.

13. Compile
Run ant. You should see something like this.

14. Deploy
Deploy your webapp to tomcat. (Simply copy the webapp folder to C:\tomcat\webapps\

15. Testing
Start your tomcat and open http://localhost:8080/webapp/ using your browser.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">