You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Nic Werner <ni...@sonoma.edu> on 2004/10/05 20:19:07 UTC

Custom Tags

I'm writing a custom tag, and using 'JavaServer Pages' as a good guide. 
Its helpful, but I'm confused about the difference between Simple Tag 
Handlers and Classic ones.
    The book states that a Simple handler 'cannot contain Java code 
(scripting elements)', but I'm seeing Java in these examples. What is 
the difference between scripting elements and just the straight Java?

Thanks,

- Nic

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Custom Tags

Posted by Hans Bergsten <ha...@gefionsoftware.com>.
Nic Werner wrote:
> I'm writing a custom tag, and using 'JavaServer Pages' as a good guide. 
> Its helpful, but I'm confused about the difference between Simple Tag 
> Handlers and Classic ones.
>    The book states that a Simple handler 'cannot contain Java code 
> (scripting elements)', but I'm seeing Java in these examples. What is 
> the difference between scripting elements and just the straight Java?

The book states, for simple tag handlers that "the _body_ of a
custom action implemented as a simple tag handler cannot contain
Java code (scripting elements); the tag handler class itself is,
of course, written in Java (or alternatively, as a tag file).

So, if you implement the tag handler as a simple tag handler, you
can not put scripting elements in the corresponding action element
in the JSP page, i.e., this is invalid:

   <foo:mySimpleTagHandler>
      <% Syste,out.println("This is invalid") %>
   </foo:mySimpleTagHandler>

If you instead implement it as a classic tag handler, the above
is valid (but not recommended; avoid scripting elements in all
pages).

Hans
-- 
Hans Bergsten                                  <ha...@hansbergsten.com>
Gefion Software                       <http://www.gefionsoftware.com/>
Author of O'Reilly's "JavaServer Pages", covering JSP 2.0 and JSTL 1.1
Author of O'Reilly's "JavaServer Faces", covering JSF 1.0
Details at                              <http://www.hansbergsten.com/>


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org