Ques: 76 Describe the <tiles:useAttribute/> and
<tiles:importAttribute/> tags in Tiles tag library in Struts framewrok?
Ans: The
<tiles:useAttribute/> tag is used to retrieve a Tiles object from the
Tiles context and expose that object as a scriptlet variable. The <tiles:useAttribute/>
tag has no body and supports five attribute:
name, id, className, scope, ignore.
The <tile:importAttribute/> tag is ues to import a Tiles
object from the Tiles context into a JSP scriptlet variable, which is stored in
the named scope. If the name and scope attributes are not included are not
included in the tag instance, then all Tile objects stored in the Tiles context
are imported and placed in page scope. The < tiles:importAttribute/> tag
has no body and supports three attributes:
name, scope, ignore.
Ques: 77 Which tag can be used to initialize the Tiles definition
factory in Struts framework?
Ans: The
<tiles:initComponentDefintions/> tag is used to initialize the Tiles
definition factory. This tag is evaluated only once or not at all if the
factory has already been initialized by other means. The
<tiles:initComponentDefinition/> has no body and supports two attributes:
* file : The file
containing your Tile definitions.(Required)
* classname : The fully
qualified classname of the definition factory being initialized. This class, if
specified, must implement the
org.apache.struts.tiles.DefinitionFactory.(Optional)
Ques: 78 What are the steps involved in installing the Logic tag
library in your Struts application?
Ans: To use the Logic tag
library in web application, You must complete the following steps:
* Copy the TLD file
packaged with this tag library struts-logic.tld) to the
webapps/MyAppName/WEB-INF directory.
* Make sure that the
struts.jar file is in the webapps/MyAppName/WEB-INF/lib directory.
* Add the following
<taglib> sub-element to the web.xml file of the Web application:
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
You must add the following taglib directive to each JSP that will
leverage the HTML tag library:
<%@ taglib
uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
Ques: 79 What is the use of <logic:empty/> and
<logic:notEmpty/> tag defined by Logic tag library in Struts framework?
Ans: The <logic:empty/>
tag evaluates its body if either the scripting variable identified by the name
attribute or a property of the named scripting variable is equal to null or an
empty string. The <logic:empty/> tag has a body type of JSP and supports
three attributes:
* name : Identifies the
scripting variable being tested.
* property : Identifies
the data member of the scripting variable ot be tested.(optional)
* scope : Defines the
scope of the bean specified by the name attribute.
The <logic:notEmpty/> tag evaluates its body if either the
scripting variable or property of the named scripting variable is not equal to
null or an empty string. The <logic:empty/> tag has a body type of JSP
and supports three attributes:
* name : Specifies a
scripting variable to be used as the variable being tested.(Required)
* property : Specifies the
data member of the scripting variable to be tested.(optional)
* scope : Defines the
scope of the bean specified by the name attribute.
Ques: 80 What is the use of <logic:equal/> and
<logic:notEqual/> tag defined by Logic tag library in Struts framework?
Ans: The <logic:equal/>
tag evaluates its body if the variable specified by any one of the attributes
cookie, header, name, property, parameter equals the constant value specified
by the value attribute. The <logic:equal/> tag has a body of JSP and
supports seven attributes:
value, cookie, header, name, property, parameter, scope.
Example:
<logic:equal name="user"
property="age"
value="<%= requiredAge
%>">
You are exactly at the
right age.
</logic:equal>
The <logic:notEqual/> tag evaluates its body if the variable
specified by any one of the attributes cookie, header, name, property,
parameter is not equal to the constant value specified by the value attribute.
The <logic:equal/> tag has a body of JSP and supports seven attributes:
value, cookie, header, name, property, parameter, scope.
Example:
<logic:notEqual name="user"
property="age"
value="<%=
requiredAge %>">
You are not at the right
age.
</logic:equal>