Struts2 Interview Questions and Answers
Struts2 Interview Questions and Answers
http://struts.apache.org/2.1.6/docs/comparing-struts-1-and-2.html
3. What are Pull-MVC and push-MVC based architecture ? Which architecture does
Struts2 follow ?
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. 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 , 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.
No,Unlike Struts2 action, Interceptors are shared between requests, so thread issues
will come if not taken care of.
Actions in Struts are POJO , is also considered as a Model. The role of Action 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 than 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.
Yes
> 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.
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.
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 on 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.
view source
print?
02.
03. ActionContext action=invoke.getInvocationContext();
04.
05. HttpServletRequest
req=(HttpServletRequest)action.get(StrutsStatics.HTTP_REQUEST);
06.
07. return null;
08.
09. }
In the similar way you can get the response, by using StrutsStatics.HTTP_RESPONSE in
get() method as above.
Q) What is the advantage of DispatchAction class? A) Using 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 [...]