Your Ad Here

Saturday, January 3, 2009

Struts Interview Questions & Answers

Q : What are the disadvantages of struts?
A : A Few Disadvantage are mentioned into the below link. Struts have disadvantages mainly on performance of the application. Especially when the using advanced tag like nested-loop etc, Resulting in creating many Forms object then required.

Q : Explain the Struts navigation flow?
Struts Navigation flow is
A request is made from previously displayed view.
The request reaches the ActionServlet which acts as the controller .The ActionServlet Looksup the requested URI in an XML file (Struts-Config.xml) and determines the name of the Action class that has to perform the requested business logic.
The Action Class is performs its logic on the Model Components associated with the Application.
Once The Action has been completed its processing it returns the control to the Action Servlet. As part of its return the Action Class provides a key to determine where the results should be forwarded for presentation.
The request is complete when the Action Servlet responds by forwarding the request to the view, and this view represents the result of the action.

Q : How do we call EJB from Struts?
A : We can call EJB from struts by using the service locator design pattern or by Using initial context with create a home object and getting return remote reference object.

Q : Explain about the token feature in Struts?
A : Use the Action Token methods are to prevent duplicate submits
There are methods built into the Struts action to generate one-use tokens. A token is placed in the session when a form is populated and also into the HTML form as a hidden property. When the form is returned, the token is validated. If validation is failed , then the form has already been submitted, and the user can be apprised.
saveToken(request)
on the return trip,
isTokenValid(request)
resetToken(request)

Q : Why we use the Struts framework in project?
A : If you use struts, there will be only one Servlet which acts as a controller (MVC) pattern. If your web application is very a simple then there is no need to use struts. If the application is big like a any banking application etc, then you should use Struts as it is very robust, makes the things simple. It’s Also has lot of readily available security features etc...


Q : What are the components of Struts?
A : Struts components are categorize into Model, View and Controller:

Model: Components like business logic /business processes and data are the part of model.
View: HTML, JSP are the view components.
Controller: Action Servlet of Struts is part of a Controller components which works as front controller to handle all the requests.

Q : What are the important methods of ActioFormn?

A : The important methods is a ActionForm are : validate() & reset().

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

Q : What’s the difference between Struts 1.0 and Struts 1.1 ?
A : The new features added to Struts1 .1 are
RequestProcessor class .
Method perform() replaced by the execute() in Struts base Action Class .
Changes to web.xml and struts-config.xml.
Declarative exception handling.
Dynamic ActionForms
Plug-ins.
Multiple Application Modules.
Nested Tags.
The Struts Validator
Change to the ORO package
Change to Commons logging
Removal of Admin actions.
Deprecation of the GenericDataSource

Q : What is a Struts?
A : A Struts is a java framework based on Model 2 architecture of JSP or popularly called Model-View-Controller architecture. It’s provides a controller for this architecture.

Q : What are the core classes of Struts?
A : The core basic classes of Struts are Action, ActionForm, ActionServlet, ActionMapping, ActionForward.

Q : How is the Struts control data flow?
A : The Struts control implements the MVC/Layers pattern through the use of ActionForwards and ActionMappings to keep the control-flow decisions out of presentation layer.


Q : What is a ActionServlet?

A : The class org.apache.struts.action.ActionServlet is the called the ActionServlet. In the the Jakarta Struts Framework this class plays the role of the controller. All the requests to the server goes through the controller. Controller is responsible for the handling all the requests.

Q : In what way Struts relates to J2EE?
A: Struts framework is a built on J2EE technologies (JSP, Servlet, Taglibs), but it is a itself not part of the J2EE standard.

Q : Explain the Struts actions?
A : A Struts action is an instance of a subclass of an Action class, which is implemented by a portion of a Web application and whose perform or execute method returns a forward.

Q : Tell me some demerits of struts?
A: It is a very robust framework and is being used to extensively in the industry. But there are some disadvantages of the Struts:
a) High Learning Curve
b) Harder to learn

Q : What is the term action mapping?
A: Struts provides a number of tag libraries that helps to create a view components easily. These tag libraries are:
Bean Tags: Bean Tags are used to access the beans and their properties.
Logic Tags: Logic Tags provides presentation logics that eliminate the need for scriptlets.
HTML Tags: HTML Tags provides tags for creating the view components like forms, buttons, etc..
Nested Tags: Nested Tags helps to work with the nested context.

0 comments:

Your Ad Here