Ok. This looks much better. I'll have to play with it a bit, and explore
things more, but it certainly makes using tags much more flexible. For
instance, we're implementing SQL reports and applying stylesheets using
a syntax that looks like this:

<zp:SelectXsl query="<%=query%>" file="showDeveloper.xsl" />

Looks like it would make more sense to transform this to:
<zp:xslTransform file="showDeveloper.xsl" >
        <zp:xmlReport query="<%=query%>">
</zp:xslTranform>

We're in the middle of moving our platform to using the JSP 1.2 with
custom tags. Writing tags is actually not that bad. The only "hard"
thing was figuring out the whole issue of passing arguments, and that
was hard only because I couldn't find a good description of the details
involved.


On Thu, Sep 12, 2002 at 12:48:21PM -0700, Hans Bergsten wrote:
> Dror Matalon wrote:
> >Hans,
> >
> >
> >Thanks for the detailed response. One more question that's somewhat
> >related.  One of the most basic and powerful features in a language is
> >the ability to chain things, but I haven't seen any indications that you
> >can do this with tags, without going into Java. For instance let's say
> >that you have a tag that does concatenation and a tag that does toupper
> >(Converts things to upper case. You'd want to do
> >
> >
> >
> ><concat> first='a' second='b' </concat> ==> 'ab'
> ><toupper> string='aaa' </toupper> ==> 'AAA'
> >
> >I'd like to be able to do something like
> ><toupper>
> >        <concat> first='a' second='b' </concat>
> ></toupper>
> >
> >And have it produce 'AB', but seems like you can't do this with custom
> >JSP tags. Am I missing something? Is there a pattern that lets you do
> >this elegantly or somewhat elegantly?
>
> Sure you can. Just correcting your syntax a bit, this would do what you
> want:
>
>   <foo:toUpper>
>     <foo:concat first="a" second="b" />
>   </foo:toUpper>
>
> If the <foo:concat> action writes its result to the current output
> stream (pageContext.getOut()), and the <foo:toUpper> action reads
> its body, converts it, and writes it to the output stream, you get
> exactly what you want.
>
> >Is this something that would be easier to do with the EL?
>
> Not the "chaining" part; it's already part of how JSP actions work,
> and there are ways to make it more efficient than what I show here
> (by explicit chaining of streams between tag handlers), but that's
> overkill for most cases.
>
> On the other hand, the EL and JSTL already supports the "concat"
> function:
>
>   <foo:toUpper>
>     <c:out value="${a}${b} plus some static text, maybe" />
>   </foo:toUpper>
>
> Here I assume that "a" and "b" are dynamic values. As you can see,
> an attribute value that accepts dynamic values can be assigned with
> more than one EL expression, optionally mixed with static text.
> Each expression is evaluated and all results are concatenated.
>
> In JSP 2.0, you don't need to use the JSTL <c:out> action for this,
> since EL expressions can then be used directly in template text:
>
>   <foo:toUpper>
>     ${a}${b} plus some static text, maybe
>   </foo:toUpper>
>
> I hope this help,
>
> Hans
>
> >On Thu, Sep 12, 2002 at 10:32:39AM -0700, Hans Bergsten wrote:
> >
> >>Dror,
> >>
> >>
> >>>Good article. I also went back and read the first part where you were
> >>>talking about the JSTL expression language.
> >>>
> >>>How would development with the expression language compare to using a
> >>>template engine like Velocity in your opinion? It seems that there's a
> >>>lot of overlapping functionality.
> >>
> >>In my opinion, JSP and Velocity are two technologies with the exact same
> >>semantics (templates that mix static content with "code" to generate
> >>dynamic content); they just use different syntax for the "code" part.
> >>With JSTL and the EL, the syntax difference is minimized, but it still
> >>exist. For instance, JSP/JSTL uses XML-element syntax for things like
> >>loops and ifs, while Velocity includes features like this in their own
> >>language. The JSTL EL only lets you access data and do simple
> >>operations, such as compare values, add values, etc.
> >>
> >>The main argument against JSP from the Velocity camp has always been
> >>that since JSP allows you to include raw Java code in the template,
> >>"it sucks" (their words, not mine). Another argument has been that it
> >>is too hard to use JSP the "right way" since writing custom tags is
> >>too hard, which I can agree with to some extent. I think JSTL and the
> >>EL is a great improvement, since it minimizes the need for both custom
> >>tags and raw Java code. JSP 2.0 will introduce an easier way to
> >>write custom tags (using a special JSP file or as a Java class as today,
> >>but with a much simpler API). The EL defined for JSP 2.0 also adds
> >>support for function calls in an EL expression, and a function is much
> >>easier to write than a custom tag (it's just a static method, declared
> >>in the TLD). These two things will make it even is easier to use JSP
> >>the "right way".
> >>
> >>Hans
> >>--
> >>Hans Bergsten           [EMAIL PROTECTED]
> >>Gefion Software         http://www.gefionsoftware.com
> >>JavaServer Pages        http://TheJSPBook.com
> >>
> >>===========================================================================
> >>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> >>JSP-INTEREST".
> >>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> >>DIGEST".
> >>Some relevant FAQs on JSP/Servlets can be found at:
> >>
> >>http://archives.java.sun.com/jsp-interest.html
> >>http://java.sun.com/products/jsp/faq.html
> >>http://www.esperanto.org.nz/jsp/jspfaq.jsp
> >>http://www.jguru.com/faq/index.jsp
> >>http://www.jspinsider.com
> >
> >
> >--
> >Dror Matalon
> >Zapatec Inc
> >1700 MLK Way
> >Berkeley, CA 94709
> >http://www.zapatec.com
> >
> >===========================================================================
> >To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> >JSP-INTEREST".
> >For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> >DIGEST".
> >Some relevant FAQs on JSP/Servlets can be found at:
> >
> > http://archives.java.sun.com/jsp-interest.html
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.jsp
> > http://www.jguru.com/faq/index.jsp
> > http://www.jspinsider.com
> >
>
> --
> Hans Bergsten           [EMAIL PROTECTED]
> Gefion Software         http://www.gefionsoftware.com
> JavaServer Pages        http://TheJSPBook.com
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://archives.java.sun.com/jsp-interest.html
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.jsp
> http://www.jguru.com/faq/index.jsp
> http://www.jspinsider.com

--
Dror Matalon
Zapatec Inc
1700 MLK Way
Berkeley, CA 94709
http://www.zapatec.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to