Struts for beginners

This tutorial explains the setting up struts for beginners.The tutorials here are intend to deploy using Tomcat webserver. Download the Tomcat webserver from http://tomcat.apache.org. Once its downloaded extract or install the tomcat server in desired directory of yours.

Download latest version of Struts from http://struts.apache.org and extract the files from the downloaded file. The downloaded file will contain set of .war files which we will copy to web-apps folder of tomcat for building up our struts application.

struts-blank.war: Blank struts application. Very handy for start building struts application from scratch. We will be using this file for building the struts application step by step.
struts-example.war: Simple Struts example application with example code and instructions. We wont be touching this file for time being as we like to learn from scratch.
struts-documentation.war: contains API and important documents for the struts application development.
Copy the struts-blan.war in web-apps folder of tomcat.
and start the tomcat server.Tomcat automatically extracts the application from .war file. Once the server started test your application by follwoing URL
http://localhost:8080/struts-blank. (Note: This URL is based on assumption that the .war file name is “struts-blank.war” and this might vary for you if the .war file name is different)

How to start Tomcat Server

One of the mail requirement for running Tomcat server is to have Java Runtime Environment(JRE) installed in machine. You can download JRE fromhttp://java.sun.com.

Once JDK is installed in your machine lets procedd to next step.

  • Creating JAVA_HOME variable

    While running Tomcat will be looking for JAVA_HOME variable to point to path where JDK is installed. You can define this variable as environment variable. I have created a batch file (setenv.bat) which will set this variable on command prompt.

    setenv.bat set JAVA_HOME=C:\JDK
    This path may vary for yours depending on your java installed directory. Save this file and run in command prompt before running tomcat server in command prompt
    (Note: If this variable is set as environment variable in machine, we dont need to have this defined in batch file and running it in command prompt)

  • Running server

    Prompt to bin directory of the Tomcat server in command promt and start server using command “catalina Start” or “catalina run” (Note : To stop server you can use Ctrl+C)