Thursday, November 12, 2015

Struts 1 2 9 Tutorial

Struts facilitates writing interlacing applications with Java.


Struts is the actual framework for developing mesh applications with the Java programming language. Struts is a layer on top of basic Java Server Pages (JSP), which are similar to Microsoft's Active Server Pages (ASP) and Open Source PHP language. These technologies allow the web developer to script code that the application executes on the web server when the page is loaded. Struts provides higher level building blocks you can leverage to rapidly deploy complete applications that run on the web server.


Instructions


Prepare the Development Environment


1. Download and install the Java Runtime Environment (JRE) version 5.0. This is an older version of Java that supports development efforts on legacy applications. If you lack a compelling reason to use Struts 1.2.9, use the latest versions of the required development tools.


2. Download and install Tomcat 5.x or another application server that supports Struts programming. You can find details on the Apache website about the various configurations that are possible and the specific steps to take for your operating system.


3. Set up a directory for your sample programs in the Apache webapps directory:


.../webapps


The web.xml and struts-config.xml files that define your application and map its components so that the Struts Action Servlet can route user requests to the correct handler.





.../webapps/samples/WEB-INF/lib


4. Download and install the Struts package into the WEB-INF/lib directory. The Apache Struts website has current and prior versions of the package. Struts 1.X is the most popular framework for building Java web applications. The 2.X represents a significant evolutionary change in the technology. If you have existing code written for the 1.X version, it is likely to require modification to work properly on a 2.X release.


5. Download and install the Standard Tag Library (JSTL) and Apache Commons reusable components into the WEB-INF/lib directory. These components support standard functions like logging and emailing, relieving you from writing and debugging code to perform these operations.


6. Create the directory structure for your first application in your webapps/samples/java directory. You will be adding a directory structure that will replicate when you have compiled and deployed your program. This allows you to give your classes common names without fear that a program by another developer will overwrite them. By convention, the directory structure uses your domain:


This separation of function allows for many presentations of the same information.9. Learn program the JSP files that will implement the view components of your application.




7. Learn the basics of programming in the Java language. Java is an object-oriented programming language with a syntax based on the C programming language. You will use standard Java programming techniques to implement functions to store and retrieve data and implement your program's application logic. Put the name of your package at the top of every Java class file and save the files in the ehow directory using the name of the class and the ".java" extension:


package com.ehow;


8. Familiarize yourself with the Struts architecture. Struts' design pattern is the "Model View Controller." This model has three major components: The data model, the view that the user sees and the controller that processes requests. When a user visits the webpage, the controller makes a request to the model to retrieve the data to display. It forwards the information to the appropriate JSP page responsible only for the user interface presentation..../webapps/samples/java/com.../webapps/samples/java/com/ehow

Build a Simple Web Application


Create a simple welcome page using HTML and CSS and save it as "index.jsp" in the samples directory. As you implement your application, you can provide links on the index page to the JSP forms that support advance application features.


10. Learn about the XML configuration files you saved in the WEB-INF directory..../webapps/samples.../webapps/samples/java.../webapps/samples/WEB-INF.../webapps/samples/WEB-INF/classes