Struts is another type of framework developed by utilizing the concepts of the Model View Controller (MVC) Pattern. With the help of the implementation of this concept provided by Struts, the users of Java can separate the various concerns of the application system and implementing a simple code for its interpretation.
Below are few major features of Struts
Q1. What is Struts?
Struts is an open-source, Model View Controller or MVC framework that can be utilized for creating website pages that are based on java. Struts utilize different segments and packages like XML, Jakarta Packages, JavaBeans, Resource Bundles, and much more. Struts extend the Java Servlet API consists of a set of own custom tag libraries.
Q2. What is front controller in Struts?
In Struts, the Front controller is basically an ActionServlet. The front uses the concept of RequestProcessor class while processing the request and the concept of Interceptors while processing the request. The front controller handles all the requests to the web application.
Q3. How do I check the installed version Struts ?
You can check the installed version of Struts by following the given steps:
Q4. List few differences between spring and Struts?
Few differences between spring and Struts are as follows:
Q5. List few useful annotations introduced in Struts2?
Some of the useful annotations introduced in Struts2 are:
struts2 - convention-plugin-x.y.z.jar.
asm - x.y.jar.
antlr - x.y.z.jar.
commons - fileupload-x.y.z.jar.
commons - io-x.y.z.jar.
commons - lang-x.y.jar.
commons - logging-x.y.z.jar.
commons - logging-api-x.y.jar.
Q6. What are the main classes which are used in Struts application?
The main classes that are used in the Struts application are as follows:
ActionServlet - It is the backbone of the whole web application.
ActionForm - It is a java bean that associates one or more ActionMappings
Action - This class is extended by the org.apache.struts.action.Action class.
Action Mapping - It is used to provide mappings for Objects to Actions.
ActionForward - It is represented as a destination for the controller, RequestProcessor, that might be directed a RequestDispatcher.forward or HttpServletResponse.sendRedirect to.
Q7. What is the difference between LookupDispatchAction and DispatchAction in Struts?
The difference between LookupDispatchAction and DispatchAction in Struts can be explained as DispatchAction selects the method to execute depending on the request parameter value which is configured in the XML file. Whereas LookupDispatchAction looks into the resource bundle file and finds out the corresponding key name.
Q8. How to access Java beans and their properties in Struct Framework?
To access Java beans and their properties in Struct Framework, Struts uses the Java introspection APIs to identify the names of the actual property getter and setter methods, so your beans can provide customized method names through the use of a BeanInfo class.
Q9. What is declarative exception handling in Struts?
In Struts, Declarative Exception Handling can be stated as the procedure of handling Exceptions declaratively through the help of XML files. The way of handling the exception is specified in the XML file. The benefit of Declarative Exception Handling is if ever there is a need to change the exception handling mechanism, changes can be made to the XML file, without the need to recompile the java code.
Q10. What is ValueStack and OGNL?
In Struts, a value stack is simply a stack that contains application-specific objects such as action objects and another model object. The objects can be put in the value stack to query them and delete them. Whereas OGNL stands for Object-Graph Navigation Language, which is a powerful expression language that is used to reference and manipulate data on the ValueStack.OGNL is based on the idea of having a root or default object within the context.
Q11. What is Custom Type Converter in Struts2?
Struts has two types of converters: local type converters and global type converters. The enumeration type Gender is used in the following action. When the request parameter needs to be injected into the gender property, we must define the converter, otherwise, struts2 cannot automatically complete the type conversion.
Q12. What is the use of token interceptor in Struts2?
In Struts2, the token interceptor ensures that only one request per token is processed. This interceptor can make sure that back buttons and double clicks don't cause unintended side effects.
Q13. How is Struts 2 different from Struts 1?
Struts 1 requires Action classes to extend an abstract base class. Struts1 uses JSTL Tags and hence are limited. Whereas an Struts 2 Action may implement an Action interface, along with other interfaces to enable optional and custom services.Struts 2 provides a base ActionSupport class to implement commonly used interfaces.
Q14. What is the purpose of Struts.xml in Struct2?
In Struct2, the struts.xml file contains the configuration information that you will be modifying as actions are developed. This file can be used to override default settings for an application.
Q15. What is default result type in Struct?
In Struct, the dispatcher result type is the default type and is used if no other result type is specified. It's used to forward to a servlet, JSP, HTML page, and so on, on the server.
Q16. How to handle exceptions in Structs?
You can follow the given steps to handle exceptions in Structs:
Q17. What is the purpose of @Result annotation in Structs?
In Struts, @Result annotation is used to specify non-convention-based results for the Struts convention handling. It is added to a class and can be used to specify the result location for a specific result code from an action method.
Q18. What are the various tag libraries available in Struts?
The various tag libraries available in Struts are:
Q19. List the design patterns used in Struts?
There are basically three types of design patterns used in Struts:
Q20. What is the difference between ForwardAction and IncludeAction in Struts?
The difference between ForwardAction and IncludeAction can be stated as: