Grzegorz,

I will state the situation differently. This is what Tomcat generates for a
body tag that declares a variable called currentObject (refer quoted
sample):

java.lang.Object currentObject = null;
acme.ItrTag _jspx_th_ko_itr_0 = (acme.ItrTag)
_jspx_tagPool_ko_itr_style_source_altstyle.get(acme.ItrTag.class);
_jspx_th_ko_itr_0.setPageContext(pageContext);
_jspx_th_ko_itr_0.setParent(_jspx_th_ko_itable_0);
_jspx_th_ko_itr_0.setSource("users");
_jspx_th_ko_itr_0.setStyle("tablen");
_jspx_th_ko_itr_0.setAltstyle("tableh");
int _jspx_eval_ko_itr_0 = _jspx_th_ko_itr_0.doStartTag();
if (_jspx_eval_ko_itr_0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
  if (_jspx_eval_ko_itr_0 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE)
{
    javax.servlet.jsp.tagext.BodyContent _bc = pageContext.pushBody();
    _bc.clear();
    out = _bc;
    _jspx_th_ko_itr_0.setBodyContent(_bc);
    _jspx_th_ko_itr_0.doInitBody();
    currentObject = (java.lang.Object)
pageContext.findAttribute("currentObject");
  }
...
  Do body stuff
...

What this means is that if your tag declares a variable that is to be
visible to script in the body of the tag you MUST buffer the output of the
body for it to be non-null first time the body is processed. Now if this is
for example a tag called MySuperPortalTag for a portal site you have these
choices:

a) Accept that your entire portal will be double buffered on the server
(this I call a waste) before being sent to the client.
b) Do not declare the variable, which defeats the purpose of taglibs being
able to declare viariables.

My theory is that it is a bug or oversight, and I would imagine taglib
develpers to be interested in this oddity. Obviously either few know about
it or my lack of formal training is showing up in my ripe old age :)

Cheers
Bob

-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED] Behalf Of Grzegorz Wrazen
Sent: Friday, September 26, 2003 8:52 PM
To: [EMAIL PROTECTED]
Subject: Re: Confusion over taglib-declared variables


what's this?


-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED] Behalf Of Bob the Builder
Sent: Monday, September 15, 2003 3:12 PM
To: [EMAIL PROTECTED]
Subject: Confusion over taglib-declared variables


Hi all,

All thanks to Bryan Basham and Boris from Kobrix for their help on my last
question.

I have come across a bit of strange behaviour which I managed to get around,
but it is still confusing. If you declare a body tag that declares a
variable at begin as follows:

  <tag>
    <name>itr</name>
    <tag-class>foo.ItrTag</tag-class>
    <body-content>JSP</body-content>
    <variable>
        <name-given>currentObject</name-given>
        <variable-class>foo.Object</variable-class>
        <declare>true</declare>
        <scope>AT_BEGIN</scope>
    </variable>
  </tag>

Tomcat (4.1) only synchronizes the "currentObject" after doStartTag() if it
returns BodyTag.EVAL_BODY_BUFFERED. Otherwise (EVAL_BODY_INCLUDE), it gets
synchronized after doAfterBody() but not after doStartTag(). Is there a
specific reason for this behaviour? Surely it is not out of the ordinary to
want JSP using the variable even if the body is not buffered. I would really
appreciate it if someone can explain this to me!

Thanks in advance
Bob

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

 http://java.sun.com/products/jsp
 http://archives.java.sun.com/jsp-interest.html
 http://forums.java.sun.com
 http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

 http://java.sun.com/products/jsp
 http://archives.java.sun.com/jsp-interest.html
 http://forums.java.sun.com
 http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

 http://java.sun.com/products/jsp
 http://archives.java.sun.com/jsp-interest.html
 http://forums.java.sun.com
 http://www.jspinsider.com

Reply via email to