Home > Articles > Open Source > Ajax & JavaScript

  • Print
  • + Share This

Tomcat's Not-so-Simple SimpleTag

For an overview of how custom tags work in JSP and of what you must do to get custom tags to do something, you can study the SimpleTag example provided in the Tomcat 3.1 distribution. In fact, the example is not such a simple tag; it illustrates quite a few aspects of custom tags. The tag in the example, called foo, creates in the HTML produced by a JSP an unordered list element whose list items contain the values of the attributes of the tag itself. Studying all the files involved with this example tag will help you to understand how the tag works.

With Tomcat running, you should be able to try the simple tag example, either by finding it from the Tomcat default index.html page or by requesting it directly using something like the URL http://localhost:8080/examples/jsp/simpletag/foo.jsp (depending on your host and port number settings). Look for that JSP file for this simple tag example in a folder with the name TOMCAT_HOME\webapps\examples\jsp\simpletag. The Java source code and compiled class files for this JSP Tag example are found in the folder TOMCAT_HOME\webapps\examples\WEB-INF\classes\examples.

Another vital part of this tag example is the tag library descriptor file for the sample Web application, which is an XML document named example-taglib.tld, in the folder TOMCAT_HOME\webapps\examples\WEB-INF\jsp.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.