Q1. What is Struts?
Ans. Struts is web frame work which develop the MVC architectural based java web application having capability to generate integrated logics of controller layer dynamically based on the logics given by developer view, model and controller. Struts provides abstraction layer on top of servlets and JSP. Struts supports validation and Tiles Frame works and I18N.
Q2. How Struts works internally?
Ans. Struts follows MVC (Model View Controller) design pattern.
Model : Which is represented as business components.
View: Which is represented as presentation at view level you have JSP`s
Controller: ActionServlet given by the frame work.
This frame work mainly depends upon two xml files.
- web.xml where you are monitoring the controller part.
- struts-config.xml where action classes are configured.
When a request is submitted, this request is handled by the controller and the ActionServlet internally checks into the struts-config.xml and identifies the corresponding action class. Instantiate that action class and execute the business logic in that action class and forwards the request to the required JSP.
Q3. Can we write our own ActionServlet for front controller of Struts Applications?
Ans. Yes you can write your own ActionServlet using below steps.
- Take any servlet it must extends predefined ActionServlet
- Call the super class methods
- Write your own logic
- It must be configure in web.xml file
Q4. What is Difference between Mvc1 architecture and Mvc2 Architecture?
Ans. In MVC1 there is no separation of presentation layer and business layer. MVC1 does not promote reusability of application components and it is used for simple applications.
In MVC2 there is easy maintenance of resulting from separation of presentation layer and business layer. Reusability of components and controller presents a single point of entry to the web application providing cleaner means of implementing security and state management.
Q5. Can we have different controllers in one struts app?
Ans. No you cannot have Struts Framework is based on Front Controller design patter which means there should be only ONE Controller (ACTION SERVLET) to controller the request and dispatching the views or responses.
Q6. What is request processor class?
Ans. Request processor is a class which is under the controller layer. This class is used to access the client request from the ActionServlet and process this request and then dispatches to the next layer i.e Model (Action class). Finally Action class calls the execute() method and it return the ActionForward to the client.
Q7. What types of Actions we have in Struts?
Ans. There are 5 types of Actions in Struts :
Q8. What is the use of DynaActionForm?
Ans. By Using DynaActionForm, you do not need to specify the setter getter methods in the form bean. The attribute for the form are specified in the xml file in the form bean tag itself. In the action class, the form is typecast into the DynaActionForm and the properties can be used in the old way. This eliminates the addition work to modify the setter and getter for the attributes when the form properties are being changed.
Q9. Which components have the struts-config file?
Ans. struts-config file having the following components