Oracle JavaServer Pages Developer's Guide and Reference Release 8.1.7 Part Number A83726-01 |
Library | Service | Contents | Index

## Overview of the JSP Markup Language (JML) Sample Tag Library

OracleJSP supplies the JSP Markup Language (JML) sample tag library, which is portable to any standard JSP environment. JML tags, as with those of any standard tag library, are completely compatible with regular JSP script and can be used in any JSP page.

Many of the JML tags are intended to simplify coding syntax for JSP developers who are not proficient with Java. There are also tags for XML transformations (as described in Chapter 5), bean binding, and general utility.

The following topics are covered here:

- JML Tag Library Philosophy

- JML Tag Categories

- JML Tag Library Description File and taglib Directive

Note the following requirements for using JML tags:

- Install the file `ojsputil.jar` and include it in your classpath. This file is provided with the OracleJSP installation.

- Make sure that the tag library description file, `jml.tld`, is deployed with the application and is in the location specified in the `taglib` directives of your JSP pages. See "JML Tag Library Description File and taglib Directive".

  Notes: OracleJSP also provides a tag library for SQL functionality. This is described in "OracleJSP Tag Library for SQL". Prior to OracleJSP release 1.1.0.0.0 and the release of the JSP 1.1 specification, OracleJSP supported JML tags only as Oracle extensions. (The tag library framework was not added to the JavaServer Pages specification until JSP 1.1.) For these releases, Oracle-specific JML tag processing was built into the OracleJSP translator. This is referred to as "compile-time JML support" and is described in Appendix C, "Compile-Time JML Tag Support".

### JML Tag Library Philosophy

JavaServer Pages technology is intended for two separate developer communities--those whose primary skill is Java programming and those whose primary skill is in designing static content, particularly in HTML, and may have limited scripting experience.

The JML tag library is designed to allow most Web developers, with little or no knowledge of Java, to assemble JSP applications with a full complement of program flow-control features.

This model presumes that the business logic is contained in JavaBeans that are developed separately by a Java developer.

### JML Tag Categories

The JML tag library covers a wide feature set. The major functional categories are summarized in Table 7-1.

##### Table 7-1 JML Tag Functional Categories

Tag Categories | Tags | Functionality
--- | --- | ---
bean binding tags | useVariable useForm useCookie remove | These tags are to declare or undeclare a JavaBean at a specified JSP scope. See "Bean Binding Tag Descriptions".
logic/flow control tags | if choose..when..otherwise foreach return flush | These tags offer simplified syntax to define code flow, such as for iterative loops or conditional branches. See "Logic and Flow Control Tag Descriptions".
XML transformation tags | transform styleSheet | These tags simplify the process of applying an XSL stylesheet to all or part of JSP page output. See "JML Tags for XSL Stylesheets".

### JML Tag Library Description File and taglib Directive

As with any tag library following the JSP 1.1 specification, the tags of the JML library are specified in an XML-style tag library description (TLD) file.

This TLD file is provided with the OracleJSP sample applications. It must be deployed with any JSP application that uses JML tags, and specified in a `taglib` directive for any page using JML tags.

#### JML taglib Directive

A JSP page using JML tags must specify the TLD file in a `taglib` directive that supplies a standard universal resource indicator (URI) to locate the file. The URI syntax is typically application-relative, such as in the following example:

    <%@ taglib uri="/WEB-INF/jml.tld" prefix="jml" %>

Alternatively, instead of using the full path to the TLD file, as in this example, you can specify a URI shortcut in the `web.xml` file then use the shortcut in your `taglib` directives. See "Use of web.xml for Tag Libraries".

For general information about tag library description files, see "Tag Library Description Files".

#### JML TLD File Listing

This section lists the entire TLD file for the JML tag library, as supported in OracleJSP release 1.1.0.0.0.

    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE taglib
            PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
            "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">

    <!-- a tab library descriptor -->

    <taglib>
      <!-- after this the default space is
     "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"
       -->

     <tlibversion>1.0</tlibversion>
     <jspversion>1.1</jspversion>
     <shortname>jml</shortname>
     <info>
      Oracle's jml tag library.  Not all of the jml
      tag's available in the Oracle JSP environment
      are provided in this library.  No jsp: tags are
      duplicated, some tags are unavailable, and some tags
      have stricter syntax.  No bean expressions are supported.

      The differences are:
       *-jml:call - not available
       * jml:choose - works as documented
       * jml:flush - works as documented
       * jml:for - works as documented
       * jml:foreach - the type attribute is required, otherwise,
        as documented
       *!jml:forward - use jsp:forward
       *!jml:getProperty - use jsp:getProperty
       * jml:if - works as documented
       *!jml:include - use jsp:include
       *-jml:lock - not available
       *!jml:plugin - use jsp:plugin
       * jml:print - the expression to print must be supplied as
        an attribute.  i.e. the tag cannot have a body
       * jml:remove - works as documented
       * jml:return - works as documented
       *-jml:set - not available
       *!jml:setProperty - use jsp:setProperty
       * jml:styleSheet - works as documented
       * jml:transform - works as documented
       *!jml:useBean - use jsp:useBean
       * jml:useCookie - works as documented
       * jml:useForm - works as documented
       * jml:useVariable - works as documented
     </info>

       <!-- The choose tag -->
     <tag>
      <name>choose</name>
      <tagclass>oracle.jsp.jml.tagext.JmlChoose</tagclass>
      <bodycontent>JSP</bodycontent>
      <info>
       The outer tag of a multiple choice logic block,
       choose
        when condition1
        when condition2
        otherwise
       end choose
      </info>
     </tag>

       <!-- The flush tag -->
     <tag>
      <name>flush</name>
      <tagclass>oracle.jsp.jml.tagext.JmlFlush</tagclass>
      <bodycontent>empty</bodycontent>
      <info>
       Flush the current JspWriter
      </info>
     </tag>

     <!-- The for tag -->
     <tag>
      <name>for</name>
      <tagclass>oracle.jsp.jml.tagext.JmlFor</tagclass>
      <teiclass>oracle.jsp.jml.tagext.JmlForTEI</teiclass>
      <bodycontent>JSP</bodycontent>
      <info>
       A simple for loop
      </info>

      <attribute>
       <name>id</name>
       <required>true</required>
      </attribute>
      <attribute>
       <name>from</name>
       <required>true</required>
       <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
       <name>to</name>
       <required>true</required>
       <rtexprvalue>true</rtexprvalue>
      </attribute>
     </tag>

     <!-- The foreach tag -->
     <tag>
      <name>foreach</name>
      <tagclass>oracle.jsp.jml.tagext.JmlForeach</tagclass>
      <teiclass>oracle.jsp.jml.tagext.JmlForeachTEI</teiclass>
      <bodycontent>JSP</bodycontent>
      <info>
       A foreach loop for iterating arrays, enumerations,
       and vector's.
      </info>

      <attribute>
       <name>id</name>
       <required>true</required>
      </attribute>
      <attribute>
       <name>in</name>
       <required>true</required>
       <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
       <name>type</name>
       <required>true</required>
      </attribute>
      <attribute>
       <name>limit</name>
       <required>false</required>
       <rtexprvalue>true</rtexprvalue>
      </attribute>
     </tag>

     <!-- The if tag -->
     <tag>
      <name>if</name>
      <tagclass>oracle.jsp.jml.tagext.JmlIf</tagclass>
      <bodycontent>JSP</bodycontent>
      <info>
       A classic if
      </info>

      <attribute>
       <name>condition</name>
       <required>true</required>
       <rtexprvalue>true</rtexprvalue>
      </attribute>
     </tag>

       <!-- The otherwise tag -->
     <tag>
      <name>otherwise</name>
      <tagclass>oracle.jsp.jml.tagext.JmlOtherwise</tagclass>
      <bodycontent>JSP</bodycontent>
      <info>
       (optional) final part of a choose block
      </info>
     </tag>

       <!-- The print tag -->
     <tag>
      <name>print</name>
      <tagclass>oracle.jsp.jml.tagext.JmlPrint</tagclass>
      <bodycontent>empty</bodycontent>
      <info>
       print the expression specified in the eval attribute
      </info>
      <attribute>
       <name>eval</name>
       <required>true</required>
       <rtexprvalue>true</rtexprvalue>
      </attribute>
     </tag>

       <!-- The remove tag -->
     <tag>
      <name>remove</name>
      <tagclass>oracle.jsp.jml.tagext.JmlRemove</tagclass>
      <bodycontent>empty</bodycontent>
      <info>
       remove the specified object from the pageContext
      </info>
      <attribute>
       <name>id</name>
       <required>true</required>
      </attribute>
      <attribute>
       <name>scope</name>
       <required>false</required>
      </attribute>
     </tag>

       <!-- The return tag -->
     <tag>
      <name>return</name>
      <tagclass>oracle.jsp.jml.tagext.JmlReturn</tagclass>
      <bodycontent>empty</bodycontent>
      <info>
       Skip the rest of the page
      </info>
     </tag>

       <!-- The styleSheet tag -->
     <tag>
      <name>styleSheet</name>
      <tagclass>oracle.jsp.jml.tagext.JmlStyleSheet</tagclass>
      <bodycontent>JSP</bodycontent>
      <info>
       Transform the body of the tag using a stylesheet
      </info>
      <attribute>
       <name>href</name>
       <required>true</required>
       <rtexprvalue>true</rtexprvalue>
      </attribute>
     </tag>

       <!-- The transform tag -->
     <tag>
      <name>transform</name>
      <tagclass>oracle.jsp.jml.tagext.JmlStyleSheet</tagclass>
      <bodycontent>JSP</bodycontent>
      <info>
       Transform the body of the tag using a stylesheet
      </info>
      <attribute>
       <name>href</name>
       <required>true</required>
       <rtexprvalue>true</rtexprvalue>
      </attribute>
     </tag>

       <!-- The useCookie tag -->
     <tag>
      <name>useCookie</name>
      <tagclass>oracle.jsp.jml.tagext.JmlUseCookie</tagclass>
      <teiclass>oracle.jsp.jml.tagext.JmlUseTEI</teiclass>
      <bodycontent>empty</bodycontent>
      <info>
       create a jml variable and initialize it to a cookie value
      </info>
      <attribute>
       <name>id</name>
       <required>true</required>
      </attribute>
      <attribute>
       <name>scope</name>
       <required>false</required>
      </attribute>
      <attribute>
       <name>type</name>
       <required>true</required>
      </attribute>
      <attribute>
       <name>cookie</name>
       <required>true</required>
      </attribute>
     </tag>

       <!-- The useForm tag -->
     <tag>
      <name>useForm</name>
      <tagclass>oracle.jsp.jml.tagext.JmlUseForm</tagclass>
      <teiclass>oracle.jsp.jml.tagext.JmlUseTEI</teiclass>
      <bodycontent>empty</bodycontent>
      <info>
       create a jml variable and initialize it to a parameter value
      </info>
      <attribute>
       <name>id</name>
       <required>true</required>
      </attribute>
      <attribute>
       <name>scope</name>
       <required>false</required>
      </attribute>
      <attribute>
       <name>type</name>
       <required>true</required>
      </attribute>
      <attribute>
       <name>param</name>
       <required>true</required>
      </attribute>
     </tag>

       <!-- The useVariable tag -->
     <tag>
      <name>useVariable</name>
      <tagclass>oracle.jsp.jml.tagext.JmlUseVariable</tagclass>
      <teiclass>oracle.jsp.jml.tagext.JmlUseTEI</teiclass>
      <bodycontent>empty</bodycontent>
      <info>
       create a jml variable and initialize it to a parameter value
      </info>
      <attribute>
       <name>id</name>
       <required>true</required>
      </attribute>
      <attribute>
       <name>scope</name>
       <required>false</required>
      </attribute>
      <attribute>
       <name>type</name>
       <required>true</required>
      </attribute>
      <attribute>
       <name>value</name>
       <required>false</required>
       <rtexprvalue>true</rtexprvalue>
      </attribute>
     </tag>

       <!-- The when tag -->
     <tag>
      <name>when</name>
      <tagclass>oracle.jsp.jml.tagext.JmlWhen</tagclass>
      <bodycontent>JSP</bodycontent>
      <info>
       one part of a choose block, see choose
      </info>
      <attribute>
       <name>condition</name>
       <required>true</required>
       <rtexprvalue>true</rtexprvalue>
      </attribute>
     </tag>

    </taglib>

| Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
Library | Service | Contents | Index