Sunday 28 June 2015

OCEJWCD.- 8.Developing JSP pages using custom tags (part 2)

OCEJWCD (SCWCD) - 1Z0-899 - Web Component Developer Certification
8.4.Write JSP code using several standard tags.

In the previous sections we have reviewed the uses of standard tags. There is the option of defining custom tags, when JSTL and standard actions are not enough.

-Using tag files ( implement tag functionality in a JSP)
-Using tag handlers (implement tag functionality in java class)
  -Simple
  -Classic (previous to JSP2.0)

Example of tagFile:

Example of simple tag handler:

- Class that extends SimpleTagSupport and override doTag() method:

- Create TLD for the tag:



- Use the tags in a JSP:

see the tag file in directive:  <%@ taglib prefix="myTag" tagdir="/WEB-INF/tags" %>
and tag handler in directive: <%@ taglib prefix="simple" uri="simpleTag" %>


Results:
In the example the tag file includes a button and the tag handler adds line with text and a checkbox.

8.5.List capabilities of JSTL tags.

  • JSTL encapsulates, as simple tags, core functionality common to many JSP applications. A single tag and can be used on multiple JSP containers.
  • JSTL provides support for core iteration and control-flow features, text inclusion, internationalizaton-capable formatting tags, and XML-manipulation tags.
  • JSTL extensibility mechanisms: a framework for integrating custom tags with JSTL tags.

OCEJWCD (SCWCD) - 1Z0-899 - Web Component Developer Certification

No comments:

Post a Comment