Home » Struts » Resources of Struts 1.x Application Development

Resources of Struts 1.x Application Development

Following are the Important Components of Struts.

  1. JSP Programs (View Layer Resources)
  2. FormBean Class(Java Class) (Controller Layer Resources)
  3. Action Servlet(Built-in Controller Servlet) (Controller Layer Resources)
  4. Action Class (Java Class) (Controller Layer Resources)
  5. web.xml (Deployment Descriptor file of web application)
  6. Struts Configuration File (XML File) (Controller Layer Resources)

JSP Programs :

JSP Program contains presentation logic to generate user interface for end users and to format the result returned by model layer.It is always recommended to develop JSP pages which contains less number of Java codes.To reduce Java Code in JSP application use following JSP Tags.

  • Struts Tag Libraries
  • JSTL Tags
  • JSP Custom Tags

FormBean Class :

A form bean is a type of Java bean. A form bean is an instance of a subclass of an ActionForm class, which stores HTML form data from a submitted client request or that can store input data from a Struts action link that a user clicked. An HTML form comprises fields in which the user can enter information.

A form-bean mapping is an entry in a Struts configuration file that maps a form bean to an action

Need of FormBean Class in Struts Application :

When a browser submits an HTML form, the Struts action servlet does as follows:

  1. Looks at the field names from the HTML form
  2. Matches them to the properties' names in the form bean
  3. Automatically calls the set methods of these variables to put the values retrieved from the HTML form

In addition, if you implement a validate method and set the validate flag in the corresponding action mapping entry in the Struts configuration file, the action servlet invokes the validate method to validate that the data that the servlet receives is of the appropriate type.

Action Servlet :

It is a built-in Controller Servlet for every Struts application.The integration logic of this servlet program will be generated dynamically based on the rules and guidelines given in Struts Configuration file.This integration logic controls and decides the flow of execution in struts application.

Action Class :

It is a Java class which extends org.apache.struts.action.Action class.
It can acts as model layer resources by having the logic to communicate with other model layer resources like EJB component, Spring Application etc.

web.xml :

The web.xml web application descriptor file represents the core of the Java web application, so it is appropriate that it is also part of the core of the Struts framework. In the web.xml file, Struts defines its FilterDispatcher, the Servlet Filter class that initializes the Struts framework and handles all requests. This filter can contain initialization parameters that affect what, if any, additional configuration files are loaded and how the framework should behave.

Struts Configuration File(xml file)

The struts-config.xml configuration file is a link between the View and Model components in the Web application. It plays an important role in building both Controller components and Application-specific configurations.This file should be created inside WEB-INF directory of the project.

Previous Next Article

comments powered by Disqus