Creating a Reusable Tag Library
See Also
To create a reusable tag library, you must create a Java Class Library project that
contains class-based tag handlers
or JSP-based tag files, or both, together with their tag library descriptors (TLD files). Then you export it by
packaging it in the web applications that need it. Then use your tags in the
appropriate JSP files. Whether or not they're packaged, you can enable code
completion by adding the libraries to the classpath of each
web application. Because the IDE supports JSP 2.0
TLD files, you can use this
procedure to use either tag handlers, tag files, or both.
To create a reusable tag library:
- Choose File > New Project.
Under Categories, select General. Under Projects, select Java Class Library.
Click Next.
-
Under Project Name, enter the name of your application.
Change the Project Location to any folder on your computer.
- Click Finish. The IDE creates the project folder.
The project is shown in the Projects window.
-
Create your tag library descriptors (the IDE puts it in the META-INF folder),
tag files (the IDE puts it in the META-INF/tags folder), and
tag handlers
(the IDE puts it in the src folder).
- Right click the project node in the Projects window or Files window
and choose Build Project from the pop-up menu. The tag library JAR file
is created in the project's dist folder.
- Right-click the project node of the web application that needs to use the tag library
and choose Properties. In the Libraries page, click Add JAR/Folder and browse to
your tag library's JAR file. When you do so, you can select the Build Required Projects
checkbox in the Libraries page, so that the tag library is automatically rebuilt whenever you build
the web project.
- Use the library's custom tags in your JSP files.
- See Also
- About Tag Libraries
- Accessing a Custom Tag from a JSP Page
- Managing the Classpath
Legal Notices