Implementing Custom Tag Libraries in Oracle9iAS Containers for J2EE
Date: 22-Jul-2002
This article explains how to implement custom tag libraries
in Oracle9iAS Containers for J2EE (OC4J). It is not a tutorial on how to write
custom tag handlers, but a tip to show as how to deploy custom tag handlers
in OC4J. Tags are used to encapsulate functionality that can be used from a
JSP page.
Create a TagHandler
The first step is to create a TagHandler. This will be a Java
class and it will be as shown here.
Edit the source and change as per your database settings.
Save this Java source in the <OC4J_HOME>\default-web-app\WEB-INF\classes\testtag
directory, where <OC4J_HOME> is the directory of your OC4J installation.
The name of the file will be EmployeeTag.java.
Now the TagHandler should be compiled. Make sure the files
classes12.jar, ojsp.jar, ojsputil.jar and servlet.jar are in the CLASSPATH.
Go to the directory <OC4J_HOME>\default-web-app\WEB-INF\classes directory
and issue the following command:
javac testtag\EmployeeTag.java
This compiles the Tag handler source.
Create a TLD file
This serves as the descriptor. The TLD will be as shown here.
Save this TLD file as taglib.tld in <OC4J_HOME>\default-web-app\WEB-INF directory.
Create a JSP file
Having created a TLD file and a Tag Handler it is time to
write a JSP (Java Server Pages) file to access this tag. The simple JSP file
is shown here. Save this file as Test.jsp in <OC4J_HOME>\default-web-app
directory.
Access the JSP
To access this JSP, start the OC4J server and access the jsp
file as follows: