I will only add to Hans note this:
If fact with BodyTag implementation put your tag output code in the
"doEndTag()" and not in the "doAfterBodyTag()"
as I have seen some TagHandler author wrongly do.
/**
* The method above gets called at the end of the BodyTag.
* We can either return SKIP_PAGE to indicate that
* the page content should be skipped, or return
* EVAL_PAGE to continuee evaluating the page.
*
*/
public int doEndTag()
throws JspTagException
{
try {
if (bodyContent != null)
bodyContent.writeOut(bodyContent.getEnclosingWriter());
}
catch (IOException e) {
throw new JspTagException( "IO Error: " + e.getMessage());
}
return EVAL_PAGE;
}
--
Peter Pilgrim
"Putting PLEASE HELP ME! URGENT HELP! in the E-Mail Subject: Line,
will probably lead to the opposite intention." << The Windows Trash Can >>
---------------------------------------- Message History
----------------------------------------
From: Hans Bergsten <[EMAIL PROTECTED]>@java.sun.com> on 24/05/2001 15:19 MST
Please respond to A mailing list about Java Server Pages specification and
reference <[EMAIL PROTECTED]>
DELEGATED - Sent by: A mailing list about Java Server Pages specification and
[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc:
Subject: Re: Custom Tags on WebLogic 6.0
Abhijeet Surve wrote:
>
--<CUT>--
>
> My questions here is thus.....
>
> 1. Is this a expected behaviour in WebLogic? because (Synatx 1) works fine
> under TOMCAT 3.2.1
> 2. Is it that if a certain tag extends BodyTagSupport then (Syntax2) is the
> only way of using it irrespective of the fact that i specify or not specify
> a body to it.
This is an area where the JSP 1.1 specification is not clear, so unfortunately
different containers deal with <tag/>, <tag></tag> and <tag>foo</tag>
differently.
More specifically, they differ in under what circumstances they call
setBodyContent() and doInitBody().
Tomcat (and some others) invokes these methods for all cases (as long as
doStartTag() doesn't return SKIP_BODY). Others invoke them only for the second
case and/or third case (i.e. when an opening and closing tag are used).
A common problem in a tag handler that assumes them to always be invoked is
using the bodyContent variable in doEndTag() without checking for null, leading
to a NullPointerException in a container.
This has been discussed in the JSP specification expert group and it will
be clarified in JSP 1.2 as follows:
<tag/>, <tag /> and <tag></tag> are all equal, and are called an "empty
tags" ("empty *elements*" would have been better ...).
<tag> </tag>, <tag><%= foo %></tag>, <tag>foo</tag> etc. are all "non-empty"
The container will only call setBodyContent() and doInitBody() for non-empty
tags, and only the BodyTag.doStartTag() returns EVAL_BODY_BUFFER.
So, given this, WebLogic is doing the right thing in your case while Tomcat is
not (it's a known bug in Tomcat 3.2.1, but it may have been fixed in later
versions).
> [...]
Hans
--<CUT>--
--
This e-mail may contain confidential and/or privileged information. If you are not the
intended recipient (or have received this e-mail in error) please notify the sender
immediately and destroy this e-mail. Any unauthorised copying, disclosure or
distribution of the material in this e-mail is strictly forbidden.
===========================================================================
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://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets