Friday, 4 May 2012

Struts interview questions 3

11.What is ActionMapping?
Action mapping contains all the deployment information for a particular Action bean. This class is to determine where the results of the Action will be sent once its processing is complete.

12.How is the Action Mapping specified ?
We can specify the action mapping in the configuration file called struts-config.xml. Struts framework creates ActionMappingobject from <ActionMapping> configuration element of struts-config.xml file

<action path="/submit"
<forward name="success" path="/success.jsp"/>
<forward name="failure" path="/error.jsp"/>

13.What is role of Action Class?
An Action Class performs a role of an adapter between the contents of an incoming HTTP request and the corresponding business logic that should be executed to process this request.

14.In which method of Action class the business logic is executed ?
In the execute() method of Action class the business logic is executed.

public ActionForward execute(
            ActionMapping mapping,
             ActionForm form,
             HttpServletRequest request,
             HttpServletResponse response)
throws Exception ;

execute() method of Action class:
  • Perform the processing required to deal with this request
  • Update the server-side objects (Scope variables) that will be used to create the next page of the user interface
  • Return an appropriate ActionForward object
15.What design patterns are used in Struts?
Struts is based on model 2 MVC (Model-View-Controller) architecture. Struts controller uses the command design pattern and the action classes use theadapter design pattern. The process() method of the RequestProcessor uses the template method design pattern. Struts also implement the following J2EE design patterns.
  • Service to Worker
  • Dispatcher View
  • Composite View (Struts Tiles)
  • Front Controller
  • View Helper
  • Synchronizer Token

No comments:

Post a Comment