Ads 468x60px

Pages

Wednesday, 4 July 2012

struts interview questions


Ques: 14 Who calls the ActionForm.validate() method inside the ActionServlet.
Ans: The RequestProcessor.process() method calls the ActionForm.validate() method, which checks the validity of the of the submitted values.

Ques: 15 What is for Action.execute() method?
Ans: The execute method is where your application logic begins. It is the method that you need to override when defining your own Actions. The execute() method has two functions:
  * It performs the user-defined business logic associated with your application.
  * It tells the Framework where it should next route the request.
The Struts framework defines two execute() methods. 
The first execute() implementation is used when you are defining custom Actions that are not HTTP specific, i.e. anlogous to the javax.servlet.GenericServlet class. 
The second, HTTP specific, You need to override the Action.execute() method and is anlogous to the javax.servlet.HttpServlet class.
Its signature is:
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpResponse response) throws IOException, ServletException{// some code here}

Ques: 16 Describe the purpose of the Action class?
Ans: The org.apache.struts.action.Action class is a most common component of the Struts Controller. This class must be extended for each specialized Struts function in your application. The collection of these Action classes is what defines your web application.
To develop your own Action class, you must complete the following steps:
  * Create a class that extends the org.apache.struts.action.Action class.
  * Implement the appropriate execute() method and add your specific business logic.
  * Compile the new Action and move it to the Web application's classpath, i.e. /WEB-INF/classes directory.
  * Add an <action> element to the application's struts-config.xml file describing the new Action.

Ques: 17 What are Struts Plugins?
Ans: Struts Plugins are modular extensions to the Struts Controller. They are defined by the org.apache.struts.action.Plugin interface.  Struts Plugins are useful are useful when you are allocating resources or preparing connections to the databases or even JNDI resources.
This interface defines two lifecycle mathods: init() and desstroy().

Ques: 18 What are the steps involved in Struts Plugins?
Ans: All Plugins must implement the two Plugin methods init() and destroy(). To develop your own Plugin You must complete the following steps:
  * Create a class that implements the org.apache.struts.action.Plugin interface.
  * Add a default empty contructor to the Plugin implementation. You must have a default constructor to ensure that the ActionServlet property creates your Plugin.
  * Implement both the init() and destroy() methods and your implementation.
  * Compare the new Plugin and move it into the web applocation's classpath.
  * Add a <plug-in> element to the application's struts-config.xml file describing the new Plugin.

Ques: 19 What is RequestProcessor? How will you create your own RequestProcessor?
Ans: The RequestProcessor is the class that you need to override when you want to customize the processing of the ActionServlet. It contains a predefined entry point that is invoked by the Struts controller with each request. The entry point is the processPreprocess() method.
Steps involved in creation your own RequestProcessor:
  * Create a class that extends the org.apache.struts.action.RequestProcessor class.
  * Add a default empty constructor to the RequestProcessor implementation.
  * Implement your processPreprocess() method.









0 comments:

Post a Comment