How to Learn Java Struts
The primary purpose of Java Servlets in the Struts framework is to handle electronic request that are made by a user's web browser or user action. The Struts framework users JavaServer Pages (JSP) to create the dynamic web pages that are sent back to the user for viewing. Using the servlet to route the view of the data to the user makes it easier for the web architect to maintain a project through the separation of data from its visual representation. In order to learn Java Struts, studying the architecture of the development environment is required.
Instructions
-
-
1
Create your Java Struts development directory structure. Most integrated development environments will automatically do this for you. The directory structure is a predefined series of folder names within your programs directory structure that Java Struts expects to find other supporting files and documents in your program.
-
2
Create the web.xml web deployment descriptor file. You can define tag libraries in the file and it will also contain the Java servlet definition and mapping for support file locations.
-
-
3
Make the struts-config.xml file. The struts-config.xml file will contain the net beans tags required for the form components that will be used in your Java Struts application. You can also choose to require input verification in this file as well as other required user-actions.
-
4
Write the Action and ActionForm classes. You will choose the properties that are represented by your input form as well as the get and set methods for all attribute properties in these classes. If you have chosen to validate the data input from the user, then the validate method is a required definition in these classes. The Action classes will decide what display on the server to display to the end-user.
-
5
Make the ApplicationResource.properties file that will have information specific for your default and other locations for the project. This file is used to display default information in the event of a user or program generated error in the program.
-
6
Create the JSP pages for the program. One Java Server Page is required for each view required by your application. Struts definition tags are used when you are requiring HTML form inputs and displaying messages back to the user through the Web browser.
-
7
Compile and deploy the application on your computer by using the "Compile and Build" option in your Integrated Development Environment. Further test your application by entering incorrect data inputs to try to force your error handling code to display the default messages you defined in the ApplicationResource.properties file.
-
1