Struts2 framework is a combined work of webwork and Struts community. Previously it was known as webwork2 which later on named as Struts2. It uses Inversion Of Control (IoC) and architectural pattern MVC(Model-View-Controller), It also enablesAspect-Oriented Programming (AOP)usingInterceptors. As Struts2 has built in support of AJAX, it is also ideally suitable for developing web 2.0 application.
Model:Action
View:JSP / Velocity Template / Freemaker
Controller:StrutsPrepareandExecuteFilter
Struts2 is a pull-MVC framework. i.e. the data that is to be displayed to user has to be pulled from the Action.
Struts2 Architectural:It leverages the standard JEE technologies such as Java Filters, JavaBeans, ResourceBundles, Locales, XML etc in its architecture.
2) What is the advantage of having a POJO class as an action?
Ans: As mentioned in the first question, the POJO classis light weight and easy to test with frameworks like Junit. Moreover, there is no need to create separate Action Forms to hold the values from the source web page.
3) How can one integrate Spring IoC with Struts 2?
Ans: Struts 2 comes with support for Spring and Spring can be used to inject beans to various \classes. It can also be used to inject properties to the action class of struts 2..
5)Mainclasses which are used instrutsapplication?
Ans:List of Main Classes
Action servlet: it’sa back-bone of web application it’s a controller class responsible for handling the entire request.
Action Class: using Action classes all the business logic is developed us call model of the application also.
Action Form: it’s a java bean which represents our forms and associated with action mapping. And it also maintains the session state its object is automatically populated onthe server side with data entered from a form on the client side.
Action Mapping: using this class we do the mapping between object and Action.
ActionForward: this class in Struts is used to forward the result from controller to destination
6)What are Pull-MVC and push-MVC based architecture ?Which architecture does Struts2 follow ?
Ans:Pull-MVC and Push-MVC are better understood with how the view layer is getting data i.e.Model to render. In case of Push-MVC the data(Model) is constructed and given to the view layer by the Controllers by putting it in the scoped variables like request or session. Typical example is Spring MVC and Struts1. Pull-MVC on the other hand puts the model data typically constructed in Controllers are kept in a common place i.e. in actions, which then gets rendered by view layer.Struts2 is a Pull-MVC based architecture, in which all data is stored in Value Stack and retrieved by view layer for rendering
7)Are Interceptors in Struts2 thread safe ?
Ans:No, This is not Thread Safe, Interceptors are shared between requests, so thread issues will come if not taken care of.
Ans:No, This is not Thread Safe, Interceptors are shared between requests, so thread issues will come if not taken care of.
8)What is the relation between ValueStack and OGNL ?
Ans: ValueStack is a place where all the data related to action and the action itself is stored. OGNL is a mean through which the data in the ValueStack is manipulated.
Ans: ValueStack is a place where all the data related to action and the action itself is stored. OGNL is a mean through which the data in the ValueStack is manipulated.
9) How Will Run the Execute Method in Action Class?
Ans Action Servelet will run the execute method in Struts,as it is the Main controller of Strus
10) Why We Use Resource Bundle in Struts2?
Ans:To use resource bundle to retrieve the message from properties file,