Magazine
 
Struts2 Tags

Apache Struts is an open-source framework used to develop Java web applications. Strut1 with all standard Java technologies and packages of Jakarta assists in creating an extensible development environment. However, with the growing demand of web applications,
Strut 1 needs to be changed with the increasing demand. This led to the creation of Strut2, which are more users friendly with the features like Ajax, rapid development and extensibility. In this section we will start introducing you with some tags provided with struts 2 framework and the rest will be included in the subsequent issues of the magazine.

Just download the zip file “struts2generictags.zip” from any link given below of each page of this article, unzip it and copy this application to the webapps directory of Tomcat. Start tomcat and write http:// localhost:8080/struts2generictags/index.jsp to the address bar. You can examine the result of each tag from thispage.


 

If you make changes in the application, run the build.xml with ant tool and restart the tomcat server.

Struts 2 tags type:
1. Struts Generic Tags

The struts generic tags are used to control the execution flow when pages are rendered. Another use of struts generic tags is data extraction.

Generic Tags are further classified into:

i) Control Tags
The Control Tags are used for flow control, such as if, else and iterate.
ii) Data Tags.
The Data Tags are used for data manipulation or creation, such as bean, push, and i18n.

2. Struts UI tags

Struts UI Tags are mainly designed to use the data from your action/value stack or from Data Tags. These tags are used to display the data on the HTML page. The UI tags are driven by templates and themes. Struts UI Tags are of two types:

i) Form Tags
ii) Non-Form Tags


This issue starts explaining struts 2 tags from Control Tags and subsequent issues will continue further.
Control Tags

1. Control Tags-If / Else If / Else
’If’ tag could be used by itself or with ‘Else If’ Tag and/or single/multiple ‘Else’ Tag. Create a JSP page IfControlTag.jsp. Set a property ‘technologyName’ with a value ‘Java’ as <s:set name=”technologyName” value=”%{‘Java’}”/>. Among if, elseif and else tags only one tag evaluates at a time. Evaluation is based upon the conditions being processed. Evaluated conditions must be of boolean type. This is illustrated in the following Jsp page. If the condition in <s:if > tag

     
 Dec 2007 | Java Jazz Up | 41
 
previous
index
next
 
View All Topics
All Pages of this Issue
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , 80 , 81 , 82 ,

Download PDF