For JSP 1.1, section 5.4.4, the descriptions of doInitBody() and
doAfterBody() both include the statement

   "Not invoked in empty tags or in tags returning SKIP_BODY."

The specific mention of "empty tags" would lead one to believe that empty
tags are treated differently.

The JSP 1.2(PFD) spec, section 10.2.2.2 merely states that doInitBody()
won't be called if there is no body evaluation.  The description for
setBodyContent() has the same statement but adds an example (e.g. if
startTag() returns EVAL_BODY_INCLUDE or SKIP_BODY) but doesn't say anything
about empty body.

Personally, I think it makes sense to call doInitBody() and doAfterBody()
for empty bodies for the same reason you give.  But the 1.1 spec (what TC
3.2 implements) makes it seem perfectly valid to not call these methods for
empty bodies.

What really irks me about this isn't the ambiguity in the specification, but
that this question was posed to [EMAIL PROTECTED] over two
months ago and, to the best of my knowledge, no one ever got any response.
I've *never* received any response to any email I've sent jsp-spec-comments.
Contrast that with [EMAIL PROTECTED]  There is an
auto-response that at least lets you know the message made it.  I've
received a personal response to every message I've ever sent there.  The
longest time to response was about 2 days, the shortest about 2 minutes.



> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Hans
> Bergsten
> Sent: Wednesday, March 14, 2001 2:48 PM
> To: [EMAIL PROTECTED]
> Subject: Re: JSP doInitBody/doAfterBody with no body
>
>
> Marc Saegesser wrote:
> >
> > The follow email discussion happened on tomcat-dev back in January.  In
> > reviewing the open bugs for Tomcat 3.2.2 I came across this
> issues again and
> > I'm trying to decide if it should dealt with, marked invalid, etc.
> >
> > Did anyone hear anything back from jsp-comments?  For that
> matter, has any
> > *ever* heard anything back from jsp-comments?  I've never
> received a single
> > response to any message I've ever sent to that address.
>
> I brought this to the JSR-053 working group yesterday, and Eduardo has
> promised to try to resolve the issue with a mail today or tomorrow.
>
> My reading of the spec, though, is that no matter if an action element has
> a body or not, all body methods must always be called if BodyTag
> is implemented.
> Not doing so means that the tag developer needs to deal with different
> usage scenarios in the code, and that should not be necessary.
>
> Hans
>
> > ------------------
> >
> > Jeff Turner wrote:
> > > Having a look through bug 652:
> > >
> > >  BodyTag doInitBody and doAfterBody called on tags without body
> > >
> > > (http://znutar.cortexity.com/BugRatViewer/ShowReport/652)
> > >
> > > I don't think this is a bug.
> > >
> > > The JSP spec, p88, says:
> > >
> > > "If an action element can have a non-empty body and is
> > > interested in the content of that body, the methods doInitBody() and
> > > doAfterBody(), defined in the BodyTag interface are involved."
> >
> > My interpretation of this is:
> > * Tag "foo" may have body
> > * <x:foo>Blah</x:foo> -> body methods called
> > * <x:foo/> -> no body methods called
> >
> > > Note, "can have", not "if it does have". So an element
> without a body, but
> > > that *could* have a body according to the TLD, still has
> do*Body methods
> > > called.
> >
> > .. if it has a body *in the usage of it*, sure. Of course. But if it's
> > not *used* with a body, then the body methods should not be called.
> >
> > > So:
> > >  <my:tag>foo</my:tag> has do*Body() called (obviously).
> > >  <my:tag></my:tag> has do*Body() called (the body will just be blank)
> > >  <my:tag/> has do*Body() called, because according to the XML
> spec, this
> > is
> > > shorthand for the <my:tag></my:tag> notation, and therefore processes
> > > equivalently.
> >
> > I see the two last ones as distinctly different, whereas the first two
> > are identical semantically. And I have a couple of tags that indeed
> > makes a major difference between <x:foo></x:foo> and <x:foo/>.
> >
> > > Interestingly, JRun3.0 has the opposite bug, and doesn't call
> > setBodyContent
> > > if the tag doesn't have a body but could.
> >
> > To me that is correct.
> >
> > > Eg, in JRun the following action breaks:
> > >
> > > <util:include url="foo.html"/>
> >
> > Why? How is this tag dependent on a body to be supplied?
> >
> > > But this works:
> > >
> > > <util:include url="foo.html"></util:include>
> > >
> > > The taglib in question is from the Jakarta Taglibs project.
> >
> > To me this hints at a bug in the Jakarta Taglibs.
> >
> > It might be beneficial to send a query about this to the JSP spec
> > writers, since it's a rather important issue. I have CC'ed
> > [EMAIL PROTECTED]
> >
> > regards,
> >   Rickard
> >
> > --
> > Rickard Öberg
> >
> > Email: [EMAIL PROTECTED]
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, email: [EMAIL PROTECTED]
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, email: [EMAIL PROTECTED]
>
> --
> Hans Bergsten         [EMAIL PROTECTED]
> Gefion Software               http://www.gefionsoftware.com
> Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]

Reply via email to