Abhijeet Surve wrote:
>
> hi guys....
>
> The problem I are facing is in the implementation of JSP Custom Tags.
>
> I am using:
> ----> BEA WebLogic Server? 6.0.(Service Pack 1)
> ----> Runtime: JDK 1.3 (e.g., the JDK that comes with WebLogic)
> ----> Our Beans and Java classes are compiled with JDK 1.2.2_007
> ----> JSP 1.1
>
> Let us say we are using a certain custom tag
>
> <test:mytag attribute="one" attribute="two" .......>
>
> This tag extends BodyTagSupport.
>
> I am using this tag in one of my jsp pages.In this jsp page I do not have a
> body to be specified for the tag.So I use the tag in the following manner in
> my jsp page.
>
> <test:mytag  label="attributevalue1"  action ="attributevalue2" /> (Synatx
> 1)
>
> As you see above, since I do not have a body to be specified for the tag I
> do a inline ending (/>) of the tag instead of doing the following:
>
> <test:mytag  label="attributevalue1"  action ="attributevalue2" >
> </test:mytag>
> (Synatx 2)
>
> If I do so I observe that the tag does not perform the expected behaviour.On
> the other hand if I follow (Synatx 2) the tag does perform the expected
> behaviour.
>
> 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
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), 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://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

Reply via email to