You are on page 1of 5

1.What is MVC?

Model-View-Controller (MVC) is a design pattern put together to help control change.


MVC decouples interface from business logic and data.
Model : he model contains the core of the application!s functionalit". he model
encapsulates the state of the application. #ometimes the onl" functionalit" it contains is
state. $t %nows nothing about the &iew or controller.
View: he &iew pro&ides the presentation of the model. $t is the loo% of the application.
he &iew can access the model getters' but it has no %nowledge of the setters. $n
addition' it %nows nothing about the controller. he &iew should be notified when
changes to the model occur.
Controller:he controller reacts to the user input. $t creates and sets the model.
More about Model-View-Controller (rchitecture ))
*.What is a framewor%?
( framewor% is made up of the set of classes which allow us to use a librar" in a best
possible wa" for a specific re+uirement.
,.What is #truts framewor%?
#truts framewor% is an open-source framewor% for de&eloping the web applications in
-a&a ..' based on MVC-* architecture. $t uses and e/tends the -a&a #er&let (0$. #truts
is robust architecture and can be used for the de&elopment of application of an" si1e.
#truts framewor% ma%es it much easier to design scalable' reliable Web applications
with -a&a.
2.What are the components of #truts?
#truts components can be categori1e into Model' View and Controller:
Model: Components li%e business logic 3business processes and data are the part of
model.
View: 4M5' -#0 are the &iew components.
Controller: (ction #er&let of #truts is part of Controller components which wor%s as front
controller to handle all the re+uests.
6.What are the core classes of the #truts 7ramewor%?
#truts is a set of cooperating classes' ser&lets' and -#0 tags that ma%e up a reusable
MVC * design.
-a&a8eans components for managing application state and beha&ior.
.&ent-dri&en de&elopment (&ia listeners as in traditional 9:$ de&elopment).
0ages that represent MVC-st"le &iews; pages reference &iew roots &ia the -#7
component tree.
<.What is (ction#er&let?
(ction#er&let is a simple ser&let which is the bac%bone of all #truts applications. $t is the
main Controller component that handles client re+uests and determines which (ction will
process each recei&ed re+uest. $t ser&es as an (ction factor" = creating specific (ction
classes based on user>s re+uest.
?.What is role of (ction#er&let?
(ction#er&let performs the role of Controller:
0rocess user re+uests
@etermine what the user is tr"ing to achie&e according to the re+uest
0ull data from the model (if necessar") to be gi&en to the appropriate &iew'
#elect the proper &iew to respond to the user
@elegates most of this grunt wor% to (ction classes
$s responsible for initiali1ation and clean-up of resources
A.What is the (ction7orm?
(ction7orm is Ba&abean which represents the form inputs containing the re+uest
parameters from the View referencing the (ction bean.
C.What are the important methods of (ction7orm?
he important methods of (ction7orm are : &alidate() D reset().
1E.@escribe &alidate() and reset() methods ?
&alidate() : :sed to &alidate properties after the" ha&e been populated; Called before
7orm8ean is handed to (ction. Feturns a collection of (ction.rror as (ction.rrors.
7ollowing is the method signature for the &alidate() method.
public (ction.rrors &alidate((ctionMapping mapping'4ttp#er&letFe+uest re+uest)
reset(): reset() method is called b" #truts 7ramewor% with each re+uest that uses the
defined (ction7orm. he purpose of this method is to reset all of the (ction7orm!s data
members prior to the new re+uest &alues being set.
public &oid reset() GH
11.What is (ctionMapping?
(ction mapping contains all the deplo"ment information for a particular (ction bean. his
class is to determine where the results of the (ction will be sent once its processing is
complete.
1*.4ow is the (ction Mapping specified ?
We can specif" the action mapping in the configuration file called struts-config./ml.
#truts framewor% creates (ctionMapping obBect from I(ctionMapping) configuration
element of struts-config./ml file
Iaction-mappings)
Iaction pathJK3submitK
t"peJKsubmit.#ubmit(ctionK
nameJKsubmit7ormK
inputJK3submit.BspK
scopeJKre+uestK
&alidateJKtrueK)
Iforward nameJKsuccessK pathJK3success.BspK3)
Iforward nameJKfailureK pathJK3error.BspK3)
I3action)
I3action-mappings)
1,.What is role of (ction Class?
(n (ction Class performs a role of an adapter between the contents of an incoming
40 re+uest and the corresponding business logic that should be e/ecuted to process
this re+uest.
12.$n which method of (ction class the business logic is e/ecuted ?
$n the e/ecute() method of (ction class the business logic is e/ecuted.
public (ction7orward e/ecute(
(ctionMapping mapping'
(ction7orm form'
4ttp#er&letFe+uest re+uest'
4ttp#er&letFesponse response)
throws ./ception ;
e/ecute() method of (ction class:
0erform the processing re+uired to deal with this re+uest
:pdate the ser&er-side obBects (#cope &ariables) that will be used to create the ne/t
page of the user interface
Feturn an appropriate (ction7orward obBect
16.What design patterns are used in #truts?
0eople who read this' also read:-
.-8 $nter&iew Luestions
ibco Luestions
#truts utorial
$ntegrating 4ibernate with #pring
#truts $nter&iew Luestions
#truts is based on model * MVC (Model-View-Controller) architecture. #truts controller
uses the command design pattern and the action classes use the adapter design
pattern. he process() method of the Fe+uest0rocessor uses the template method
design pattern. #truts also implement the following -*.. design patterns.
#er&ice to Wor%er
@ispatcher View
Composite View (#truts iles)
7ront Controller
View 4elper
#"nchroni1er o%en

You might also like