You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by "Scott M. Stirling" <ss...@mediaone.net> on 2001/01/03 07:23:58 UTC

Ant Taglib - first draft

Hi,

Here's first cut of an Ant tasks taglib.  It's small, so please don't
expect too much.  It's more of a proof of concept really.

The tasks that I have fully implemented as tags so far are:

echo, fail, gzip, gunzip, mkdir and touch.

I am attaching the source  (ant-tags.tar.gz) in typical Jakarta taglib
layout.

If you build and deploy on Tomcat, just copy the built doc and examples
war files to the webapps
dir.  By default the two apps will serve up at:

http://127.0.0.1:8080/ant-tags-examples/
http://127.0.0.1:8080/ant-tags-doc/

Read the overview of the ant-tags.html doc (the default doc if you build
and deploy the ant-tags-doc app) for a description of the taglib's
purpose and goals, and to see the documentation described below.

I spent a considerable amount of time on the documentation process.
That deserves another email.  Basically, following Craig McClanahan's
idea of generating the TLD and the main HTML doc from a single XML file,
I have perfected the production of Jakarta Taglib docs like Glenn has
for each tag library on the Web site.  I've even added some simple
syntax highlighting to the JSP examples in the generated HTML, which
you'll see if you deploy and browse to the ant-tags-doc app.  More on
this subject, with a template XML file that everyone can discuss, modify
and use to generate their own docs and TLD, hopefully  tomorrow.

Best regards,

Scott Stirling
West Newton, MA

Re: Ant Taglib - first draft

Posted by Pierre Delisle <pi...@sun.com>.
Oooppss... I hate it when I rush an email ('cause I'm late getting the
kids) and then realize two minutes later that there's lots of bogus stuff
in it... [Oh well, I must have been drinking the kool-aid :-(]

Apologies... my last comments on co-existing tag-libraries makes no
sense (since package names would have to change from one version
to the next one).

I guess my only valid comments are what's below:


> Personally, if I can get away from modifying yet another config
> file when I add new functionality to my web-site, I'm all for it
> (ease of use... how many people have been confused with the
> many steps required to integrate a new taglib in a webapp?).
> 
> This is why I'd prefer a tag library to specify a <uri> in the
> TLD that I can use directly in my taglib directive. Then all
> I need to do is drop the jar file in my WEB-INF/lib.

Having the <uri> specified as
"http://jakarta.apache.org/taglibs/ant-tags" (no version specified)
would fit the bill.

> But this being said, here is some more food for thought...
> 
> * Some people in the servlet community also dislike
>   the fact that JSP specific configuration information is included
>   in web.xml. Count on more discussions on the topic in the near
>   future.

    -- Pierre

[now rushing back to the kitchen to fix dinner...]

Re: Ant Taglib - first draft

Posted by Pierre Delisle <pi...@sun.com>.
Mike Cannon-Brookes wrote:
> 
> > If the <uri> tag is defined as follows in the TLD:
> >
> >         <uri>http://jakarta.apache.org/taglibs/ant-tags-1.0</uri>
> >
> > then under a JSP 1.2 compliant container (such as tomcat-4.0), all a
> > user has to do to use the tag library is to:
> >         1. copy the jar file into the /WEB-INF/lib subdirectory of
> >            the web application.
> >         2. add the taglib directive at the top of each page using it:
> >             <%@ taglib
> > uri="http://jakarta.apache.org/taglibs/ant-tags-1.0"
> >                 prefix="foo" %>
> 
> IMHO this is pretty silly, and I'd love to know the reasons for it. I'd
> personally use something like
> 
> <%@ taglib uri="ant-tags" prefix="ant" %>
> 
> And then define the <taglib> in the web.xml. That way you can upgrade the
> ant taglib (for example to 1.1) without changing every JSP that uses it?
> Standard abstraction stuff?


I guess there are different ways to look at it. Versioning is always
a delicate issue.

Personally, if I can get away from modifying yet another config
file when I add new functionality to my web-site, I'm all for it
(ease of use... how many people have been confused with the
many steps required to integrate a new taglib in a webapp?).

This is why I'd prefer a tag library to specify a <uri> in the
TLD that I can use directly in my taglib directive. Then all 
I need to do is drop the jar file in my WEB-INF/lib.

If as a taglib consumer I want a new version of a library to 
*totally* replace an older version, then it would be great if that
tag library's uri was something like
"http://jakarta.apache.org/taglibs/ant-tags" (no version specified).

However, I'd think there could be cases where one would want multiple 
versions of a tag library to co-exist (e.g. until new version 
of a library is fully tested at my web site, I may want to restrict
its usage to a subset of pages). Then I'd want the uris to be:
  "http://jakarta.apache.org/taglibs/ant-tags-1.0"
  "http://jakarta.apache.org/taglibs/ant-tags-1.1"
  ...
so that pages can use different versions of the taglib, still without
having to deal with web.xml.
If at one point I want to switch all my pages to use the latest 
and greatest version, I could then add an entry in the web.xml
which maps the older version to the new one (no need to modify
each page individually).

But this being said, here is some more food for thought...

* Some people in the servlet community also dislike
  the fact that JSP specific configuration information is included
  in web.xml. Count on more discussions on the topic in the near
  future.

* What if the semantics of the taglib directive were expanded to handle 
  a version number?
  [The TLD already has tag <tlibversion>, but it is currently just
  informative.]

For example:
    <%@ taglib uri=""http://jakarta.apache.org/taglibs/ant-tags"
               prefix="ant" version="1.0" />

This directive would pickup version 1.0 of the 
taglib specified, if it exists. If it does not exist, it 
could default to the latest version of the library currently
available to my webapp.

The following:
    <%@ taglib uri=""http://jakarta.apache.org/taglibs/ant-tags"
               prefix="ant"/>

would always pick-up the latest version.

    -- Pierre

RE: Ant Taglib - first draft

Posted by Mike Cannon-Brookes <mc...@internet.com>.
> If the <uri> tag is defined as follows in the TLD:
>
>         <uri>http://jakarta.apache.org/taglibs/ant-tags-1.0</uri>
>
> then under a JSP 1.2 compliant container (such as tomcat-4.0), all a
> user has to do to use the tag library is to:
>         1. copy the jar file into the /WEB-INF/lib subdirectory of
>            the web application.
>         2. add the taglib directive at the top of each page using it:
>             <%@ taglib
> uri="http://jakarta.apache.org/taglibs/ant-tags-1.0"
>                 prefix="foo" %>

IMHO this is pretty silly, and I'd love to know the reasons for it. I'd
personally use something like

<%@ taglib uri="ant-tags" prefix="ant" %>

And then define the <taglib> in the web.xml. That way you can upgrade the
ant taglib (for example to 1.1) without changing every JSP that uses it?
Standard abstraction stuff?

Mike


Re: Ant Taglib - first draft

Posted by Pierre Delisle <pi...@sun.com>.
Scott,

Great stuff!

One quick comment about the TLD. 

If the <uri> tag is defined as follows in the TLD:

        <uri>http://jakarta.apache.org/taglibs/ant-tags-1.0</uri>

then under a JSP 1.2 compliant container (such as tomcat-4.0), all a 
user has to do to use the tag library is to:
        1. copy the jar file into the /WEB-INF/lib subdirectory of 
           the web application. 
        2. add the taglib directive at the top of each page using it:
            <%@ taglib uri="http://jakarta.apache.org/taglibs/ant-tags-1.0" 
                prefix="foo" %>
 
There is no need to 
        3. Copy the tag library descriptor file to the /WEB-INF subdirectory 
           of the web application. 
        4. Add a <taglib> element to the web application deployment 
           descriptor in /WEB-INF/web.xml 

This change does not affect usage under a JSP1.1 container, and makes
life easier under JSP1.2. (see section 7.3.3 of the JSP 1.2 PFD for
more details on "implicit map in tag libraries" which was added in 1.2.)

Thanks again!

    -- Pierre

[Agree that I can simply use the following taglib directive
   <%@ taglib uri="WEB-INF/lib/ant-tags.jar" prefix="foo" %>
 and all works fine, but it is preferable to refer to these
 libraries using their public URI that uniquely identifies a specific
 version of the tag library]


"Scott M. Stirling" wrote:
> 
> Hi,
> 
> Here's first cut of an Ant tasks taglib.  It's small, so please don't
> expect too much.  It's more of a proof of concept really.
> 
> The tasks that I have fully implemented as tags so far are:
> 
> echo, fail, gzip, gunzip, mkdir and touch.
> 
> I am attaching the source  (ant-tags.tar.gz) in typical Jakarta taglib
> layout.
> 
> If you build and deploy on Tomcat, just copy the built doc and examples
> war files to the webapps
> dir.  By default the two apps will serve up at:
> 
> http://127.0.0.1:8080/ant-tags-examples/
> http://127.0.0.1:8080/ant-tags-doc/
> 
> Read the overview of the ant-tags.html doc (the default doc if you build
> and deploy the ant-tags-doc app) for a description of the taglib's
> purpose and goals, and to see the documentation described below.
> 
> I spent a considerable amount of time on the documentation process.
> That deserves another email.  Basically, following Craig McClanahan's
> idea of generating the TLD and the main HTML doc from a single XML file,
> I have perfected the production of Jakarta Taglib docs like Glenn has
> for each tag library on the Web site.  I've even added some simple
> syntax highlighting to the JSP examples in the generated HTML, which
> you'll see if you deploy and browse to the ant-tags-doc app.  More on
> this subject, with a template XML file that everyone can discuss, modify
> and use to generate their own docs and TLD, hopefully  tomorrow.
> 
> Best regards,
> 
> Scott Stirling
> West Newton, MA
> 
>   ----------------------------------------------------------------------------------------------------
>                       Name: ant-tags.tar.gz
>    ant-tags.tar.gz    Type: Unix Tape Archive (application/x-tar)
>                   Encoding: base64