How will you configure Plugins in your struts configuration file?
The <plug-in> element is used to add Plugins to the Struts Controller. Struts Plugins are useful when allocating resources or preparing connections to databases or even JNDI resources. The <plug-in> element has a single attribute, className, which is used to define the fully qualified Plugin class.
<plug-in className="Fully qualified plugin class name" />Reply
How will you add a message Resource in your struts config file?
The <message-resources> element is used to describe a MessageResources object for the containing application.
<message-resources parameter="configuration parameter" key="main" />
The attribute of a <message-resources> Element: className, factory, key, null, parameter.Reply
Describe the attributes of <action> sub-element?
The attributes of <action> Sub-Element:
* path : Represents the context-relative path of the submitted request.
* type : Specifies the fully qualified class name of the Action class being described by this ActionMapping.
* name : Identifies the name of the form bean, if any, that is coupled with Action being defined.
* scope : Specifies the scope of the form bean that is bound to the desired Action. The default value is session.
* input : Represents the context-relative path of the input form to which control should be returned if a validation error is encountered.
* className : Specifies the fully qualified class name of the ActionMapping implementation class you want to use in when invoking this Action class.
* forward : Represents the context-relative path of the servlet or JSP resource that will process this request.
* include : Represents the context relative path of the servlet or JSP resource that will process this request. This attrubute is used if you do not want an Action to service the request to this path.Reply
What is for <action-mapping> sub elements in struts config file?
The <action-mapping> sub-element is used to define n-number of <action> sub-elements. It acts as a container for <action> sub-elements.
The <action> sub-element is used to describe an Action instance to the ActionServlet.
What is Global forwards and define its attributes in struts config file?
The <global-forwards> sub-elementis used to define n-number of <forward> sub-elements that are available to any Action in the Struts Application. It acts as a container for public <forward> sub-elements.
You can use <forward> sub-elements to describe a mapping of a logical name to a context relative URI path. A forward is used to identify the target of an Action class when it returns its result.
The Attributes of a <forward> sub element:
* name : Contains the unique identifier identifying this target.
* path : Specifies the Context relative path of the targeted resource.(required)
* redirect : If set to true, causes the ActionServlet to use the HttpServletResponse.sendRedirect() method, as opposed to RequestDispatcher.forward() method, when sending the Action results to the targeted resourse. The default value is false.(optional)Reply
What are the various attributes of an <exception> sub-element in struts config file?
The attribute of an <exception> sub-element:
* bundle : A ServletContext attribute that names the resource bundle associated with the ExceptionHandler handling the defined <exception> elements.
* className : The fully qualified class name of the configuration bean associated with the defined handler.
* hanler : The fully qulified class name of the ExceptionHandler that will process the contained <exception> sub-element.
* key : Used to retrieve the message template associated with this exception.
* path : The module-relative path that will act as the target of the ExceptionHandler associated with this exception.
* scope : The scope of the ActionError object coupled with this exception.(optional)
* type : The fully qualified class name of the exception defined by this <exception> sub-element.(required).Reply
How you can add the Global exception in your configuration file?
The <global-exception> sub-element is used to define n-number of <exception> sub-elements that are throwable by any Action in a Struts application. This sub-element acts as a container for all public <exception> sub-element.
The <exception sub-element> is used to associate a global exception with an ExceptionHandler.
The following declaration in struts-config.xml:
How will you add FormBean Definitions in your struts configuration file?
The <form-bean> sub-element is used to describe an instance of a FormBean that is later bound to an Action.
<form-bean name="unique bean name" type="fully qualified class name">
How can you add a DataSource in your struts-config file?
The first component that we configure is a DataSource.
<set-property property="driverClass" value="com.mysql.jdbc.Driver"/>
<set-property property="url" value="jdbc:mysql://localhost:3306/mydb"/>
<set-property property="user" value="root" />
<set-property property="password" value="password" />
What is Tile controllers? How will you create your own Tile Controllers?
If you are putting too much java code into your Tile layout, or you have to put the same Java code into every Action that forwards to a page that uses a particular Tile layout, then you should use the Tile Controller.
The Controller class is similar to an Action. You can map model objects into scope so that the Tile can display the items. To write a Tile Controller, follow these steps:
* Create a class that implements org.apache.struts.tiles.Controller.
* Implement the perform method.
* In the perform method, do something with the model and map the results into scope so that Tile can use it. Reply