Struts Tags

Struts Tags are widely used in the struts application.For creation of a new bean includes one of the standard Struts framework configuration objects we used strut tag. This tag used to get back the value of the specified Struts internal configuration object, and defines it as a scripting variable, which is accessible as a remainder of the current page and as a attribute of  page scope. The commonly used strut tags are,

A)    Strut HTML tag: – The tags in the Struts HTML library form a bridge between a JSP view and the other components of a Web application. Since a dynamic Web application often depends on gathering data from a user, input forms play an important role in the Struts. Consequently, the majority of the HTML tags involve HTML forms.  The mainly used HTML tags are listed below.

1)      base: – The base tag provides an HTML <base> Element.

2)      button: – This tag provides a Button Input Field.

3)      cancel: – This tag provides a Cancel Button.

4)      checkbox: – This tag provides a Checkbox Input Field.

5)      errors: – This tag helps conditionally display a set of accumulated error messages.

6)      file: – It ender a File Select Input Field.

7)      form: – This tag used to define an Input Form.

8)      frame: – Frame tag provides an HTML frame element.

9)      hidden: – It provides a Hidden Field.

10)  html: – It provides an HTML <html> Element.

11)  image: – It provides an input tag of type “image”.

12)  img: – It provides an HTML img tag.

13)  javascript: – It provides JavaScript validation based on the validation rules loaded by the ValidatorPlugIn.

14)  link: – This tag provides an HTML anchor or hyperlink.

15)  messages: – The message tag displays a set of accumulated messages.

16)  multibox: – This tag provides a Checkbox Input Field.

17)  option: – It provides a Select Option.

18)  options: – It provides a Collection of Select Options.

19)  optionsCollection: – This tag provides a Collection of Select Options.

20)  password: – this tag provides a Password Input Field.

21)  radio: – It provides a Radio Button Input Field.

22)  reset: – It provides a Reset Button Input Field.

23)  rewrite: – It provides an URI.

24)  select: – The select tag provides a Select Element.

25)  submit: – The submit tag provides a Submit Button.

26)  text: – It provides an Input Field of Type text.

27)  textarea: – this tag provides a Textarea.

28)  xhtml: – This tag provides HTML tags as XHTML.

B)    Strut logic tag: – The strut tag library includes tags that are useful in managing conditional generation of output text, looping over object collections for repetitive generation of output text, and application flow management.

1)      empty: – It evaluates the nested body content of this tag if the requested variable is either null or an empty string.

2)      equal: – This tag evaluates the nested body content of this tag if the requested variable is equal to the specified value.

3)      forward: – The forward tag forward control to the page specified by the specified ActionForward entry.

4)      greaterEqual: – It evaluates the nested body content of this tag if the requested variable is greater than or equal to the specified value.

5)      greaterThan: – It evaluates the nested body content of this tag if the requested variable is greater than the specified value.

6)      Iterate: – It repeat the nested body content of this tag over a specified collection.

7)      lessEqual: – It evaluates the nested body content of this tag if the requested variable is less than or equal to the specified value.

8)      lessThan: – It evaluates the nested body content of this tag if the requested variable is less than the specified value.

9)      Match: – It evaluates the nested body content of this tag if the specified value is an appropriate substring of the requested variable.

10)  messagesNotPresent: – It generates the nested body content of this tag if the specified message is not present in this request.

11)  messagesPresent: – It generates the nested body content of this tag if the specified message is present in this request.

12)  notEmpty: – It evaluate the nested body content of this tag if the requested variable is neither null, nor an empty string, nor an empty java.util.Collection (tested by the .isEmpty() method on the java.util.Collection interface).

13)  notEqual: – It evaluates the nested body content of this tag if the requested variable is not equal to the specified value.

14)  notMatch: – It evaluates the nested body content of this tag if the specified value is not an appropriate substring of the requested variable.

15)  notPresent: – It generates the nested body content of this tag if the specified value is not present in this request.

16)  Present: – This tag generates the nested body content of this tag if the specified value is present in this request.

17)  Redirect: – It provides an HTTP Redirec.

Struts logic tag follows some rules:-

The equal, greaterEqual, greaterThan, lessEqual, lessThan and notEqual tags are applying the following rules.

1)      The specified value is examined. If it can be converted successfully to a double or a long, it is assumed that the ultimate comparison will be numeric (either floating point or integer). Otherwise, a String comparison will be performed.

2)      The variable to be compared to be retrieved based on the selector attribute(s) (cookie, header, name, parameter, property) present on this tag. It will be converted to the appropriate type for the comparison, as determined above.

3)      If the specified variable or property returns null, it will be coerced to a zero-length string before the comparison occurs.

4)      The specific comparison for this tag will be performed, and the nested body content of this tag will be evaluated if the comparison returns a true result.

The match and notMatch tags apply the following rules.

1)      The specified variable is retrieved, based on the selector attribute(s) (cookie, header, name, parameter, property) present on this tag. The variable is converted to a String, if necessary.

2)      A request time exception will be thrown if the specified variable cannot be retrieved, or has a null value.

3)      The specified value is checked for existence as a substring of the variable, in the position specified by the location attribute, as follows: at the beginning (if location is set to start), at the end (if location is set to end), or anywhere (if location is not specified).