lessEqual Tag - If the requested variable is either less or equal to the specified values then we use this tag to evaluate the contents contained in the nested body parts of this tag.
This tag compares the variable against the specified constant value. If the variable is less than or equal to the specified value then the nested body contents of this tag is evaluated
Attributes of lessEqual Tag
Attribute Name | Description |
---|---|
cookie | The variable contains the cookie value needed to compare .Here the name is specified by this attribute. |
header | The variable contains the header value needed to compare whose name is specified by this attribute. The name match is performed in a case insensitive manner. |
name | The variable to be compared is the JSP bean specified by this attribute, if |
parameter | The variable to be compared is the first, or only, value of the request parameter specified by this attribute. |
property | The variable contains the bean property value needed to compare ,it is specified by this attribute. The property reference can be simple, nested, and/or indexed. |
scope | This specifies the bean scope within which the bean is searched by the |
value | The constant value is specified by other attribute(s) of this tag, needed to compare |
Logic LessThan Tag (... )
lessThan Tag- If the requested variable is less than the specified values then we use this tag to evaluate the contents contained in the nested body parts of this tag.
This tag compares the variable against the specified constant value. If the variable is less than the specified value then the nested body contents of this tag is evaluated
Attributes of lessThan Tag
Attribute Name | Description |
---|---|
cookie | The variable contains the cookie value needed to compare .Here the name is specified by this attribute. |
header | The variable contains the header value needed to compare whose name is specified by this attribute. The name match is performed in a case insensitive manner. |
name | The variable to be compared is the JSP bean specified by this attribute, if |
parameter | The variable to be compared is the first, or only, value of the request parameter specified by this attribute. |
property | The variable contains the bean property value needed to compare ,it is specified by this attribute. The property reference can be simple, nested, and/or indexed. |
scope | This specifies the bean scope within which the bean is searched by the |
value | The constant value is specified by other attribute(s) of this tag, needed to compare |
Example Illustrating the use of the lessEqual and the lessThan logic tags.
Here you will learn to use the Struts Logic tags. We will cover an example that will show a comparison between the two logic tags (ie..
Example code
Creating an Action Class
Develop a simple action class LogicAction.java.
|
Creating Form Bean
Our form bean class contains only one property number. Here is the code of FormBean (Logic
Form
.java)
|
Defining form Bean in struts-config.xml file
Add the following entry in the struts-config.xml file for defining the form bean
LogicForm " /> |
Developing the Action Mapping in the struts-config.xml
Here, Action mapping helps to select the method from the Action class for specific requests.
Developing the InputLogic.jsp page
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %> Using <logic> TagsEnter a number:The <logic:lessEqual>tag works if you enter a valueless than or equal to 100The <logic:lessThan>tag works if you enter a valueless than to 10000 |
Developing the output.jsp page
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %> Here's Your Data...The number entered is:
|
Add the following line in the index.jsp to call the form.
Example demonstrates how LogicAction Class works.
Building and Testing the Example
To build and deploy the application go to Struts\Strutstutorial directory and type ant on the command prompt. This will deploy the application. Open the browser and navigate to the InputLogic.jsp page. Your browser displays the following page.
Writing a number equal to 101 to the InputLogic.jsp page displays the working of the lessThan Logic tag
It displays the following out.jsp page
Now write data equal 100 to the InputLogic.jsp to compare the working of the lessEqual and lessThan tags
Here both tags are evaluated it displays the output.jsp as
0 comments:
Post a Comment