Ads 468x60px

Pages

Wednesday, 4 July 2012

struts interview questions



Ques: 1 What is struts? 
Ans: Struts is a web framework software that is given based on core technologies called Servlets, JSPs and capable of developing MVC2 architecture based web applications having the ability to generate Integration logic of Controller layer dynamically based on other logics and resources supplied by the programmer in model and view layers.This allows the programmer to develop MVC2 architecture based web sites having good productivity.
Doing more work in less time with good accuracy is called productivity.

Ques: 2 What are the various steps involved in the implementaion of struts? 
Ans: The struts framework models its server side implementation of the MVC using a combination of JSPs, custom JSP tags, and a Java Servlet. It involves the following steps : 


* The incoming request is received by the ActionServlet, which acts as the controller, and the ActionServlet looks up the requested URI in an XML file. 

* The ActionClass performs its logic on the Model components associated with the application. 

* Once the Action has completed its processing, it returns control to the ActionServlet with a key that indicates the result of its processing. ActionServlet uses this key to determine where this result should be forwarded for presentation. 

* The request is complete when the ActionServlet response by forwarding the request ot the view that was linked to the returned key, and this view presents the result of the Action. 

Ques: 3 What is MVC design pattern? 
Ans: MVC stands for Model-View-Controller. The MVC design pattern is originated from Smalltalk, consists of three components : a Model, a View, and a Controller. 

MODEL : Represents the data objects. The Model is what is being manipulated and persented to the user. Model contains the business logic of the application. 

VIEW : Serves as screen representation of the Model. It is the object that represents the current state of the objects. 

CONTROLLER : Defines the way the user interface reacts to the user's input. The Controller component is the object that manipulates the Model, or data object. 

Ques: 4 How will you install struts framework in your web application? 
Ans: The follwing steps are involved to install struts framework in your web application : 

* Uncompress the Struts Archive to your local disk. 

* Create a new web Application say, MyStrutsApp inside the webapps directory under the tomcat directory. 

* Copy all the jar files, extracted from the lib directory into the /webapps/MyStrutsApp/WEB-INF/lib directory. 

* Create an empty web.xml file and copy it to the /webapps/MyStrutsApp/WEB-INF/ directory. 

* Create an empty struts-config.xml file and copy it to the /webapps/MyStrutsApp/WEB-INF/ directory. The struts-config.xml file is the diployment descriptor for all Struts applicattion. It is the file that glues all of the MVCcomponents together.

Ques: 5 Describe the struts specific form tag? 
Ans: Instead of using the standard HTML Form tag, like most HTML pages, the struts specific Form tag is : 

<html:form action="" name="" type=""> 

.......... 

</html:form> 

This tag with its subordinate input tags, encapsulates Struts form processing. The Form tag attributes are : 

* action : Represents the URL to which this form will be submitted. This is also used to find the appropriate ActionMapping in the Struts configuration file. 

* name : Identifies the key that is used to lookup the appropriate ActionForm that will represent the submitted form data. 

* type : Names the fully qualified classname of the form bean you want to use in this request. 

To use the struts specific <html:form> tag you have to use the taglib directive: 

<%@ taglib uri="WEB-INF/struts-html.tld" prefix="html" %> 

Ques: 6 What is ActionForm in the struts? 
Ans: When an <html:form/> is submitted, the Struts framework populates the matching data members of the ActionForm with the values entered in the <html:form/> tag. The Struts framework does this by using JavaBean introspection. This is all done by the class specified in the type attribute of the <html:form/> tag. This class will extends the org.apache.struts.action.ActionForm, as must all ActionForm objects with a get and set accessor that match its data members.











0 comments:

Post a Comment