Day 14. JSP Tag Libraries

In the previous two days' chapters, you have learned about J2EE Web applications written using servlets and JSPs. You have seen how servlets are most useful when complex Java programming is needed and JSPs are more appropriate to use when the generated Web page requires large amounts of HTML (or JavaScript). So far, to support complex features, you have had to write Java code in JSP in the form of scriptlets. There is another way, however. JSTL (JavaServer Pages Standard Tag Library) and custom tag libraries (TagLibs) provide a natural extension to the JSP tag syntax.

JSTL has been developed to make writing JSPs easier. It has the following advantages:

  • Removes the need for JSP writers to manipulate the dynamic data using Java code.

  • Supports the JSP Expression Language (EL).

  • Provides comprehensive support for common JSP requirements.

JSTL provides many of the features required by JSP authors but does not remove entirely the need for Java code. This is where custom tags come in.

Custom tags are written entirely in Java in separate classes and made available to the JSP through a Tag Library Descriptor (TLD) file.

In today's chapter, you will see how to

  • Use JSTL and EL to replace JSP scriptlets

  • Deploy the agency case study with the JSTL tag libraries

  • Write simple custom tags

  • Write a TLD XML deployment descriptor for Tag Libraries

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.143.32