Book Image

Java EE 5 Development with NetBeans 6

Book Image

Java EE 5 Development with NetBeans 6

Overview of this book

Table of Contents (17 chapters)
Java EE 5 Development with NetBeans 6
Credits
About the Author
About the Reviewers
Preface
Identifying Performance Issues with NetBeans Profiler

Custom JSP Tags


Sometimes we need to add very similar snippets of HTML to our pages. For example, we might have a calendar component used to input all dates in our system, or we might have a specific format for all address input fields in our application.

Although we can certainly copy and paste the code throughout all JSP pages that need it in our application, this approach is not very desirable, since, if we need to make a change to the common code, we need to go through all the pages and make individual modifications. When using JSPs, we can create custom JSP tags. These JSP tags allow us to create the HTML code we need in one place, then we simply use the tag in any page that requires it. NetBeans has great support for helping us develop custom JSP tags.

Creating a JSP tag is not much different than creating a JSP. To create a JSP tag, a tag file is created, it needs to be placed under the WEB-INF/tags folder in our application, or in any subdirectory of this directory.

To create a custom...