Java

What is the directory structure of Struts application?

The directory structure of Struts application :

What is the ActionForm?

ActionForm is javabean which represents the form inputs containing the request parameters from the View referencing the Action bean.

What are the important methods of ActionForm? What are the important methods of ActionForm?

The important methods of ActionForm are : validate() & reset().

What is ActionMapping?

Action mapping contains all the deployment information for a particular Action bean. This class is to determine where the results of the Action will be sent once its processing is complete.

.How is the Action Mapping specified ?

We can specify the action mapping in the configuration file called struts-config.xml. Struts framework creates ActionMapping object from <ActionMapping> configuration element of struts-config.xml file

<action-mappings> <action path=”/submit” type=”submit.SubmitAction” name=”submitForm” input=”/submit.jsp” scope=”request” validate=”true”> <forward name=”success” path=”/success.jsp”/> <forward name=”failure” path=”/error.jsp”/> </action> </action-mappings>

What is role of Action Class?

An Action Class performs a role of an adapter between the contents of an incoming HTTP request and the corresponding business logic that should be executed to process this request.

What is ActionServlet?

ActionServlet is a simple servlet which is the backbone of all Struts applications. It is the main Controller component that handles client requests and determines which Action will process each received request. It serves as an Action factory – creating specific Action classes based on user’s request.

What is role of ActionServlet?

ActionServlet performs the role of Controller:

  • Process user requests
  • Determine what the user is trying to achieve according to the request
  • Pull data from the model (if necessary) to be given to the appropriate view,
  • Select the proper view to respond to the user
  • Delegates most of this grunt work to Action classes
  • Is responsible for initialization and clean-up of resources

What is Struts framework?

Struts framework is an open-source framework for developing the web applications in Java EE, based on MVC-2 architecture. It uses and extends the Java Servlet API. Struts is robust architecture and can be used for the development of application of any size. Struts framework makes it much easier to design scalable, reliable Web applications with Java.

What are the components of Struts?

Struts components can be categorize into Model, View and Controller:

  • Model: Components like business logic /business processes and data are the part of model.
  • View: HTML, JSP are the view components.

Controller: Action Servlet of Struts is part of Controller components which works as front controller to handle all the requests.