Question: How Struts
relates to J2EE?
Answer: Struts framework is built on J2EE technologies
(JSP, Servlet, Taglibs),
but it is itself not part of the J2EE standard.
Question: What is Struts actions and action mappings?
Answer: 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 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.
An
action servlet is a servlet
that is started by the servlet container of a Web
Server to process a request that invokes an action. The servlet
receives a forward from the action and asks the servlet
container to pass the request to the forward’s URL. An action servlet must be an instance of an org.apache.struts.action.ActionServlet
class or of a subclass of that class. An action servlet
is the primary component of the controller.
Question: Can I setup Apache Struts to use multiple
configuration files?
Answer: Yes Struts can use multiple
configuration files. Here is the configuration example:
banking
org.apache.struts.action.ActionServlet config
/WEB-INF/struts-config.xml,
/WEB-INF/struts-authentication.xml,
/WEB-INF/struts-help.xml
Question: What are the disadvantages of Struts?
Answer: Struts is very robust framework
and is being used extensively in the industry. But there are some disadvantages
of the Struts:
a) High Learning Curve
Struts requires lot of efforts to learn and master it. For any small
project less experience developers could spend more time on learning the Struts.b) Harder to learn
Struts are harder to learn, benchmark and optimize.
Question: What is Struts Flow?
Answer: Struts Flow is a port of Cocoon’s
Control Flow to Struts to allow complex work flow, 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 is based on a
proof-of-concept Dave son put together to show how the Control Flow could
be extracted from Cocoon. (Ref:http
://struts.sourceforge.net/struts-flow/index.html
)
Question: What are the difference
between and ?
Answer: : This tag is used
to output locale-specific text (from the properties files) from a MessageResources bundle.
:
This tag is used to output property values from a bean. is a commonly used
tag which enables the programmers to easily present the data.
Question: What is LookupDispatchAction?
Answer: 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).
Question: What are the components of
Struts?
Answer: Struts is based on the MVC design patterns. Struts components can
be categories intoModel, 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 all the
requests.
Question: What are Tag Libraries provided
with Struts?
Answer: Struts provides a number of tag libraries that helps to create
view components easily. These tag libraries are:
a) Bean Tags: 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.
Question: What are the core classes of
the Struts Framework?
Answer: Core classes of Struts Framework are ActionForm,
Action, ActionMapping, ActionForward,
ActionServlet etc.
Question: What are difference between ActionErrors and ActionMessage?
Answer: 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 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).
Question: How you will handle exceptions
in Struts?
Answer: 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 .. tag.
Example:
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.
No comments:
Post a Comment