design pattern t he Interceptors in Struts2 is based on ?
Interceptors in struts are based on Intercepting Filters. 3.
What
are Pull-MVC and pus h-MVC based architecture ? Struts2 follow ?
Which
architecture does
Pull-MVC and Push-MVC are better understood with with how the t he 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. Typical example is Spr ing MVC and Struts1. Pull-MVC on the other hand puts put s the model data typically constructed in Controllers are kept in a common place , which then gets rendered by view layer. Struts2 is a Pull-MVC based architecture, in which a ll data is stored in Value Stack and retrieved by view layer for rendering. 4. Are Interceptors in Struts2 t hread safe ? No,Unlike Struts2 action, Interceptors are shared between requests, so thread issues will come if not taken care of. 5. Are Interceptors and Filters different ? , If yes t hen how ? 6. In Struts1, the front-controller was a Servlet but in Struts2, it is a filter. possible reason to c hange it to a filter ? 7. Which class is the front-controller in Struts2 ?
What
is the
The class "org.apache.struts2.dispatcher.FilterDispatcher " is the front controller in Struts2. In recent time t ime Struts 2.1.3 this class is deprecated and new c lasses are introduced to do the job. Refer: http://struts.apache.org/2.1.8/struts2core/apidocs/org/apache/struts2/dispatcher/FilterDispatcher.html
8.
What
is the role of Action/ Model ?
Actions in Struts are POJO , is also considered co nsidered as a Model. The role of Action Act ion are to execute business logic or delegate call to business logic by the means of action methods which is mapped to request and contains business data to be used by the view layer by means of setters and getters inside the Action class and finally helps the framework decide which result to render
9.
How
does Interceptors help achieve Struts2 a better framework t han Struts1 ? 10. What is the relation between ValueStack and OGNL ?
A 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. 11. Can annotation-based and XML based configuration of actions coexists ? Yes 12. What is struts.devMode and w hy it is used ? struts.devMode is a key used in struts.properties file (Can also be configured in struts.xml file as ) , to represent whether the framework is running in development mode or production mode by setting true or false. If set to development mode, it gives the following benefits : > Resource bundle reload on every request; i.e. all localization properties file can be modified and the change will be reflected without restarting the server. > struts.xml or any configuration files can be modified without restarting or redeploying the application > The error occurs in the application will be reported, as oppose to production mode. Also remember that struts.devMode should be marked as false in production environment to reduce impact o f performance. By default it is "false". 13. How do you configure t he annotation based action mapping ? 14. What is the difference between empty default namespace and root name space ? If the namespace attribute is not defined in the package tag or assigned "" value then it is called empty default namespace.While if "/" is assigned as value to the namespace attribute then it is called as root namespace. The root namespace is treated as all other explicit namespaces and must be matched. It¶s important to distinguish between the empty default namespace, which can catch all request patterns as long as the action name matches, and the root namespace, which is an actual namespace that must be matched. 15. Which interceptor is responsible for setting action's JavaBean properties ? com.opensymphony.xwork2.interceptor.ParametersInterceptor is the interceptor class who sets the action's JavaBean properties from request.
16. What is the difference between Action and ActionSupport ? Action is interface defines some string like SUCCESS,ERROR etc and an execute() method. For convenience Developer implement this interface to have access to String field in action methods. ActionSupport o n other hand implements Action and some other interfaces and provides some feature like data validation and localized error messaging when extended in the action classes by developers. 17. How do you get the HttpServletRequest object in an interceptor ? Here is the intercept method view source print? 01.public String intercept(ActionInvocation invoke) throws Exception { 02. 03.
In the similar way you can get the response, by using StrutsStatics.HTTP_RESPONSE in get() method as above. 18.
What
is execute and wait interceptor ?
19.Difference between errortag and message tag » Q) What is the difference between errorstag and message tag? Rep) Errorstag genereates the error for Ex: <%@ taglib uri=/tags/struts-html prefix=html %> O/P of rs.jsp When the errors tag is evaluated a list of error message will be generated based on the ActionError objects available in ActionErrors object. while generating the list of errors [...] Q) What is the advantage of DispatchAction class? A) Usi ng DispatchAction class you can overcome writing one Action class for one business entity. Instead you can write multiple business entities in one Action class and call the business method that is required by the application. Q) Can you write your own method in Action class [...]