Struts Tutorial for Beginners
- 1). Understand the MVC (Model-View-Controller) architecture of Struts. The MVC architecture breaks down an application's components into three integral categories--Model, View and Controller. Each of the three components has separate functions, and is unique and independent, meaning that changes in one will have no effect on the others. The Model component of MVC provides data from a database and saves it to the data store. Data access and validation are also parts of the Model component. In View, the user is able to view the application, and takes inputs and forwards the request to the controller. The response from the controller is then displayed to the user. The final component, Controller, receives requests from the client and executes the applicable logic from the Model, before generating the output using the View component.
- 2). Set up the development environment. Download and install three core components essential for the Struts framework, which are the Java Development Kit, the Tomcat application server to execute Java applications and the Struts framework. Download Java Development Kit from a trusted site and follow instructions in the manual to complete the installation process.
- 3). Download and install Tomcat. Check installation by navigating to the directory where you installed, and initiating the start-up command to run the server. Next, open a browser such as Internet Explorer or Mozilla Firefox and type in "http://localhost:8080/" to test the server. Your browser should display the welcome page.
- 4). Download and install the latest version of Struts from a dependable site. Extract the downloaded file into a specified directory, right-click the file and choose where you want to extract. Copy three items, "struts-blank.war," "struts-documentation.war" and "struts-example.war" to the directory labeled "jakarta-tomcat-5.0.4\webapps," from the "jakarta-struts-1.1\webapps" directory.
- 5). Understand the significance of the three moved items. The first file, "struts-blank.war" is a blank application which you will use to create a web application from scratch. The next file, "struts-documentation.war," contains important information and documents necessary for application development in Struts. Finally, the "struts-example.war" file is a MailReader Demonstration Application.
- 6). Set up a project. Change the name of the "struts-blank.war" file to " struts-tutorial.war" and copy the renamed file to the directory labeled "jakarta-tomcat-5.0.4\webapps." This action will prompt the application server (Tomcat) to extract the file and load the application automatically.
- 7). Learn the basic actions in developing Java applications and practice with the Struts framework. Learn about JSP (JavaServer Pages) and ActionForm and use the elements to create a small application. Run and debug small applications.
Source...