Explain about validator-rules.xml and validation.xml files ?

Validator framework is used to validate the form data and you no need to write any code in your form bean for validations and storing the error messages.Your Form Bean, extending one of the Validator’s Action Form subclasses, does the required validations.If you do not use Validator, you need to handle the data validations in [...]

What is difference between ActionForm and DynaActionForm

If the ActionForm is used, then user himself has to write the setters and getters when ever he adds a control. The same process is repeated again and again when user creates a view. DynaActionForm eliminates this burden and creates the form bean itself. This way user dont have to write setters and getters. No [...]

Describe validate() and reset() methods ?

validate() : ActionForm class provides a validate() method hook that can be overridden by subclasses to perform validations on incoming form data.The validate() method hook gets called after a Form Bean has been populated with incoming form data. Following is the method signature for the validate() method
public ActionErrors validate(ActionMapping mapping,HttpServletRequest request)
validate() method has return type [...]

Explain deployment descriptor(web.xml) configuration for struts application ?

Action Servlet and strtus-config.xml files and configured as below
<servlet>      <servlet-name>action</servlet-name>      <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>      <init-param>         <param-name>config</param-name>         <param-value>/WEB-INF/struts-config.xml</param-value>       </init-param></servlet>
This config parameter tells the Strut’s Action Servlet where to find its central configuration file struts-config.xml
<servlet-mapping>             <servlet-name>action</servlet-name>             <url-pattern>*.do</url-pattern><servlet-mapping>
In servlet mapping <url-pattern> tag is sayinng that ActionServlet should process any requests for pages thats end in .do
Tag Library descriptors will be configured as [...]

Is Struts Thread Safe ?

Struts is not only thread-safe but thread-depenedent. The response to a requeast is handled by light weight Action object, rather than an individual servlet.Struts instanciate each Action class once and allows other request to threaded through the orginal object. This core strategy conserves resources and provides the best posible throughput. A properyly-designed application will exploit [...]

81. How you will make available any message resources definations file to the struts famework environment.

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 <message-resources /> tag.Example:<message-resources parameter=”MessageResources” />

80. What is Jakarta Struts FrameWork

Jakarta Struts is open source implementation of MVC (Model-View-Controller) pattern for the development of web based applications. Jakarta Struts is robust architecture and can be used for the development of application of any size. Struts framework makes it much easier to design scalable, reliable Web applications with Java.

79. What are the core classes of the Struts Frame Work

Core classes of Struts Framework are ActionForm, Action, ActionMapping, ActionForward, ActionServlet etc.

78. What are the components of Struts

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.
View: JSP, HTML etc. are part of View
Controller: Action Servlet of Struts is part of Controller components which works as front controller to handle [...]

77. What are differences between <bean:message> and <bean:write>

<bean:message>: This tag is used to output locale-specific text (from the properties files) from a MessageResources bundle. 
<bean:message key=”label.search.name”/>
<bean:write>: This tag is used to output property values from a bean. <bean:write> is a commonly used tag which enables the programmers to easily present the data.
<bean:write name=”student” property=”age”/>

76. What is LookupDispatchAction

An abstract Action that dispatches to the subclass mapped execute method. This is useful in cases where an HTML form has multiple submit buttons with the same name. The button name is specified by the parameter property of the corresponding ActionMapping.
(Ref. http://struts.apache.org/1.2.7/api/org/apache/struts/actions/LookupDispatchAction.html).

75. What is struts flow

Struts Flow is a port of Cocoon’s Control Flow to Struts to allow complex workflow, like multi-form wizards, to be easily implemented using continuations-capable JavaScript. It provides the ability to describe the order of Web pages that have to be sent to the client, at any given point in time in an application.
The code [...]

74. How to handle exceptions in struts

In Struts you can handle the exceptions in two ways:a) Declarative Exception Handling: You can either define global exception handling tags in your struts-config.xml or define the exception handling tags within <action>..</action> tag. Example:
<exception   key=”database.error.duplicate”                     path=”/UserExists.jsp”                     type=”mybank.account.DuplicateUserException”/>
b) Programmatic Exception Handling: Here you can use try{}catch{} block to handle the exception.

73. What is the Action Errors and Action Message?

ActionMessage: A class that encapsulates messages. Messages can be either global or they are 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 [...]

72. How to setup struts to use multiple configuration files.

Struts can use multiple configuration files. Here is the configuration example:<servlet>        <servlet-name>banking</servlet-name>        <servlet-class>org.apache.struts.action.ActionServlet        </servlet-class>        <init-param>        <param-name>config</param-name>        <param-value>/WEB-INF/struts-config.xml,                /WEB-INF/struts-authentication.xml,                /WEB-INF/struts-help.xml           </param-value>    </init-param>

71. What we will define in struts-config.xml file.

The main control file in the Struts framework is the struts-config.xml XML file, where action mappings are specified.
This file’s structure is described by the struts-config DTD file, which is defined at http://jakarta.apache.org/struts/. A copy of the DTD can be found on the /docs/dtds subdirectory of the framework’s installation root directory. The top-level element is [...]

70. What is the request processor in struts and how it works

The RequestProcessor Class is the actual place where the request processing takes place in a Struts controller environment.
When the request object first reaches the actionservlet class then it invokes the process method of the underlying RequestProcessor Class.
This process method then looks into the struts-config.xml file and tries to locate the name of the action that [...]

69. What is struts actions and action mappings.

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, in general, associates an action [...]

68. What are the various struts tag libraries.

Struts is very rich framework and it provides very good and user friendly way to develop web application forms. Struts provide many tag libraries to ease the development of web applications. These tag libraries are:

Bean tag library – Tags for accessing JavaBeans and their properties.
HTML tag library – Tags to output standard HTML, including forms, [...]

67. What is the difference between perform() and execute()

Perform method is the method which was deprecated in the Struts Version 1.1. 
In Struts 1.x, Action.perform() is the method called by the ActionServlet. This is typically where your business logic resides, or at least the flow control to your JavaBeans and EJBs that handle your business logic.
As we already mentioned, to support declarative exception [...]

66.How to enable front-end validation based on the xml in validation.xml

The <html:javascript> tag to allow front-end validation based on the xml in validation.xml.
For  example the code:
<html:javascript  formName=”logonForm”                          dynamicJavascript=”true”                          staticJavascript=”true”  />
 generates the client side java script for the form “logonForm” as defined in the  validation.xml file.
The <html:javascript> when added in the jsp file generates the client site validation script.
Following tag displays [...]

65. What is the Struts Validator Framework

Struts Framework provides the functionality to validate the form data.
It can be use to 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 [...]

64. What is Action Class

The Action is part of the controller. 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.
The ActionServlet (commad) passes the parameterized class to Action Form using the execute() method.
There should be no database interactions in [...]

63. Explain ActionFrom Class and its life cycle.

An ActionForm is a java bean that extends org.apache.struts.action.ActionForm, ActionForm maintain the session state of web application.
All data submitted by the user are sent corresponding ActionForm 
ActionForm class is used to capture user-input data from an HTML form and transfer it to the Action Class. ActionForm plays the role of Transport Vehicle between the presentation Tire & Business [...]

62. What are new features of Struts 1.1

The new features added to Struts 1.1 are
1. RequestProcessor class 2. Method perform() replaced by execute() in Struts base Action Class 3. Changes to web.xml and struts-config.xml4.Declarative exception handling5.Dynamic ActionForms6.Plug-ins7.Multiple Application Modules8.Nested Tags9.The Struts Validator10.Change to the ORO package11.Change to Commons logging12.Removal of Admin actions13. Deprecation of the GenericDataSource.

61. What is a Action Servlet

public class ActionServlet
extends javax.servlet.http.HttpServlet

ActionServlet provides the “controller” in the Model-View-Controller (MVC) design pattern for web applications that is commonly known as “Model 2″.
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 [...]