R4R
Right Place For Right Person TM
 

R4R Java Core Java Faqs
Previous

Home

Next

Struts Basic questions and answers

What are difference between ActionErrors and ActionMessage?

Ans:ActionMessage: ActionMessage  class encapsulates messages. Messages can be either global or specific to a particular bean property.Each individual message is described by an ActionMessage object, which contains a message key (to be looked up in an appropriate message resources database), and up to four placeholder arguments used for parametric substitution in the resulting message.
ActionErrors:
A class that encapsulates the error messages being reported by the validate() method of an ActionForm. Validation errors are either global to the entire ActionForm bean they are associated with, or they are specific to a particular bean property (and, therefore, a particular input field on the corresponding form).

What are the core classes of the Struts Framework?
Ans:
ActionForm, Action, ActionMapping, ActionForward, ActionServlet etc.  

 

Struts Objective Questions And Answers

Struts Objective Questions And Answers

Struts Subjective Questions And Answers

Struts Subjective Questions And Answers

Struts Interview Questions And Answers

Struts Interview Questions And Answers
 

 

What is Struts Validator Framework?
Ans:
Struts Framework provides the functionality to validate the form data. It can be used for validate the data on the users browser as well as on the server side. Struts Framework emits the java scripts and it can be used validate the form data on the client browser. Server side validation of form can be accomplished by sub classing your From Bean with DynaValidatorForm class. The validate Framework uses two xml files.First one is validation.xml and other one is validator-rules.xml .The validate frame work was developed by David Winterfelt as third party .But now the Validator Framework is a part of Jakarta Commons Project and it can be used with or without Struts. The Validator framework comes integrated with the Struts Framework and can be used without doing any extra settings.

Give the Details of XML files used in Validator Framework?
Ans:
The Validator Framework uses two XML configuration files one is validator-rules.xml and second one validation.xml.The validator-rules.xml defines the standard validation routines. These routines are reusable and used in validation.xml to define the form specific validations. The validation.xml defines the validations applied to a form bean.

What are Tag Libraries provided with Struts?
Ans: Struts Frameworks
provides a number of tag libraries that helps to create view components in easy way.
These tag libraries are:
a) Bean Tags:
The bean Tags are used to access the beans and their properties.
b)HTML Tags:
HTML Tags provides tags for creating the view components like forms, buttons, etc.
c) Logic Tags:
Logic Tags provides presentation logics that eliminate the need for scriptlets.

d)Nested Tags:
Nested Tags helps to work with the nested context.  

What are the components of Struts?
Ans:
Struts is based on the MVC design pattern. Struts components can be categories into Model, View and Controller.
Model:
Components like business logic / business processes and data are the part of Model. Java Bean is used .
View:
JSP, HTML etc. are part of View
Controller:
Controller is backbone of any struts application. ActionServlet of struts is part of Controller components which works as front controller to handle all the requests.

What is Struts actions and action mappings?
Ans:
A Struts action is an instance of a subclass of an Action class, which implements a portion of a Web application and whose perform or execute method returns a forward. An action can perform tasks such as validating a user name and password.
An action mapping is a configuration file entry that is associates an action name with an action. An action mapping can contain a reference to a form bean that the action can use, and can additionally define a list of local forwards that is visible only to this action.

What is MVC Architecture?
Ans:
MVC stands for Model ViewController. MVC pattern is a collaboration of three components model, view and controller.Model is backend database or java bean.View is output html or jsp.Controller is logic that is servlet.MVC pattern is a sequence of action interactions starting with view,then controller and then to model based on the data persistence. MVC is an approach for developing interactive application i.e. it results in events through user interactions.Model is responsible for holding the application state, View is for displaying the current model and controller handles the event..

How to get data from the velocity page in a action class?
Ans:
We can get the values in the action classes by using data.getParameter(”variable name defined in the velocity page”)

How you will enable front-end validation based on the xml in validation.xml?
Ans:
The tag to allow front-end validation based on the xml in validation.xml. For example the code: generates the client side javascript for the form \”logonForm\” as defined in the validation.xml file. The when added in the jsp file generates the client site validation script.

 What is ActionForm?
Ans:
An ActionForm is a JavaBean that extends org.apache.struts.action.ActionForm. ActionForm maintains the session state for web application and the ActionForm object is automatically populated on the server side with data entered from a form on the client side.
What is Action class?
Ans:
The Action class is part of the Model and is a wrapper around the business logic. The purpose of Action Class is to translate the HttpServletRequest to the business logic. To use the Action, we need to subclass and overwrite the execute() method. In the Action class all the database/business processing are done. It is advisable to perform all the database related stuffs in the Action Class. The ActionServlet  passes the parameterized class to ActionForm using the execute() method. The return type of the execute method is ActionForward which is used by the Struts Framework to forward the request to the file as per the value of the returned ActionForward object.

What is ActionServlet?
Ans:
The class org.apache.struts.action.ActionServlet is the called the ActionServlet. In the the Jakarta Struts Framework this class plays the role of controller. All the requests to the server goes through the controller. Controller is responsible for handling all the requests.
 
How you will make available any Message Resources Definitions file to the Struts Framework Environment?
Ans:
Message Resources Definitions file are simple .properties files and these files contains the messages that can be used in the struts project. Message Resources Definitions files can be added to the struts-config.xml file through tag. The message stored into message resources file is in key/value pairs.

Struts Basic questions and answers

Previous

Home

Next

New Updates

R4R
R4R
R4R
R4R
R4R
R4R
R4R
R4R