You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Justin Kennedy <ju...@maritimesource.ca> on 2004/09/07 07:57:51 UTC

tag reuse, setParent and findAncestorWithClass

Hi,

 

I'm upgrading our tag library to Tomcat 5 and having problems. Note that
they were written back in JSP 1.1 and haven't changed for a few years.

 

The problem looks like the tags are being cached and the setParent isn't
being called for each new "reuse". As a result the wrong tag is returned
from findAncestorWithClass when the WriteValueTag is re-used in a
different nested block. Maybe this is how the spec was designed and I
just don't know the right way to code the tags. Anyway here's what the
JSP page looks like (note: transacttag issues a call to the database.
Writevaluetag writes the value of a column from the data returned from
transacttag. If 'transactId' isn't passed to WriteValueTag, it will use
the findAncestorWithClass to find the enclosing IterateTag to determine
the transactId):

 

<trans:transact id="uis" action="main_uis"/>

<logic:iterate transactId="uis" column="uiid">

  <logic:equal value='<%=tmpuiid%>' column="uiid">

    a - <trans:writeValue column="UI_NAME" /><br>

    <trans:parameters id="params" scope="request">

        <trans:addParameter parametersId="params" key="UIID" value='<%=
tmpuiid %>'/>

    </trans:parameters>

    <trans:transact id="ui" action="sub_uis" parametersId="params" /> 

        <logic:exists transactId="ui" column="description">

            <logic:iterate transactId="ui" column="ui_flowid">

                #1 - <trans:writeValue column="UI_NAME" /><br>

                #2 - <trans:writeValue transactId="ui"
column="FORM_NAME"/><br>

                #3 - <trans:writeValue column="FORM_NAME"/><br>

            </logic:iterate>

        </logic:exists>

  </logic:equal>

</logic:iterate>

 

 

The problems:

1.	UI_NAME in #1 is a column from the first "uis" transactTag. The
writeValueTag prints out the value of this column but it shouldn't
behave this way because it's enclosed IterateTag has a different
"transactId". I put this here to demonstrate the problem
2.	FORM_NAME in #3 is a column in the second transactTag of "ui".
This column value SHOULD be output (like it has always done) because the
enclosed iterateTag specifies the proper transactId, but this value is
not output because it's parent is set to the first IterateTag and not
the second, hence the different transactIds.

 

#2 works only because I'm explicitly setting the transactId. 

 

The WriteValueTag extends the TagSupport class and everything is done in
the doStartTag event.

 

Please advise,

-Justin

 


RE: tag reuse, setParent and findAncestorWithClass

Posted by Justin Kennedy <ju...@maritimesource.ca>.
Thanks Tim, I got it working!

-----Original Message-----
From: Tim Funk [mailto:funkman@joedog.org] 
Sent: Tuesday, September 07, 2004 10:07 AM
To: Tomcat Users List
Subject: Re: tag reuse, setParent and findAncestorWithClass

Turn off tag pooling.

-Tim

Justin Kennedy wrote:

> Hi Tim,
> 
> I read through the link you posted but I don't see any references to
> setParent. I understand that setParent is only called once when the
> attributes for a tag are the same (because it's reused), so how should
I
> go about developing the inner tag so the parent will always be set? I
> read up on SimpleTag and that could be the answer, but I'm worried
about
> performance with this because the writevalue tag is called many many
> times on one page.
> 
> Thanksk
> 
> -----Original Message-----
> From: Tim Funk [mailto:funkman@joedog.org] 
> Sent: Tuesday, September 07, 2004 7:59 AM
> To: Tomcat Users List
> Subject: Re: tag reuse, setParent and findAncestorWithClass
> 
> http://jakarta.apache.org/tomcat/faq/misc.html#tagbroken
> 
> -tim
> 
> Justin Kennedy wrote:
> 
>>Hi,
>>
>> 
>>
>>I'm upgrading our tag library to Tomcat 5 and having problems. Note
> 
> that
> 
>>they were written back in JSP 1.1 and haven't changed for a few years.
>>
>> 
>>
>>The problem looks like the tags are being cached and the setParent
> 
> isn't
> 
>>being called for each new "reuse". As a result the wrong tag is
> 
> returned
> 
>>from findAncestorWithClass when the WriteValueTag is re-used in a
>>different nested block. Maybe this is how the spec was designed and I
>>just don't know the right way to code the tags. Anyway here's what the
>>JSP page looks like (note: transacttag issues a call to the database.
>>Writevaluetag writes the value of a column from the data returned from
>>transacttag. If 'transactId' isn't passed to WriteValueTag, it will
> 
> use
> 
>>the findAncestorWithClass to find the enclosing IterateTag to
> 
> determine
> 
>>the transactId):
>>
>> 
>>
>><trans:transact id="uis" action="main_uis"/>
>>
>><logic:iterate transactId="uis" column="uiid">
>>
>>  <logic:equal value='<%=tmpuiid%>' column="uiid">
>>
>>    a - <trans:writeValue column="UI_NAME" /><br>
>>
>>    <trans:parameters id="params" scope="request">
>>
>>        <trans:addParameter parametersId="params" key="UIID"
> 
> value='<%=
> 
>>tmpuiid %>'/>
>>
>>    </trans:parameters>
>>
>>    <trans:transact id="ui" action="sub_uis" parametersId="params" /> 
>>
>>        <logic:exists transactId="ui" column="description">
>>
>>            <logic:iterate transactId="ui" column="ui_flowid">
>>
>>                #1 - <trans:writeValue column="UI_NAME" /><br>
>>
>>                #2 - <trans:writeValue transactId="ui"
>>column="FORM_NAME"/><br>
>>
>>                #3 - <trans:writeValue column="FORM_NAME"/><br>
>>
>>            </logic:iterate>
>>
>>        </logic:exists>
>>
>>  </logic:equal>
>>
>></logic:iterate>
>>
>> 
>>
>> 
>>
>>The problems:
>>
>>1.	UI_NAME in #1 is a column from the first "uis" transactTag. The
>>writeValueTag prints out the value of this column but it shouldn't
>>behave this way because it's enclosed IterateTag has a different
>>"transactId". I put this here to demonstrate the problem
>>2.	FORM_NAME in #3 is a column in the second transactTag of "ui".
>>This column value SHOULD be output (like it has always done) because
> 
> the
> 
>>enclosed iterateTag specifies the proper transactId, but this value is
>>not output because it's parent is set to the first IterateTag and not
>>the second, hence the different transactIds.
>>
>> 
>>
>>#2 works only because I'm explicitly setting the transactId. 
>>
>> 
>>
>>The WriteValueTag extends the TagSupport class and everything is done
> 
> in
> 
>>the doStartTag event.
>>

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




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


RE: tag reuse, setParent and findAncestorWithClass

Posted by Justin Kennedy <ju...@maritimesource.ca>.
Tim,

I added this to my tomcat_home/conf/web.xml:

    <servlet>
        <servlet-name>jsp</servlet-name>
 
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
        <init-param>
            <param-name>enablePooling</param-name>
            <param-value>false</param-value>
        </init-param>
    </servlet>

I put it right after:
<web-app>

But I still see the same behavior. Note: This setting is not overridden
in the web.xml for my webapp... I tried putting it there too but no
luck.

Thanks

-----Original Message-----
From: Tim Funk [mailto:funkman@joedog.org] 
Sent: Tuesday, September 07, 2004 10:07 AM
To: Tomcat Users List
Subject: Re: tag reuse, setParent and findAncestorWithClass

Turn off tag pooling.

-Tim

Justin Kennedy wrote:

> Hi Tim,
> 
> I read through the link you posted but I don't see any references to
> setParent. I understand that setParent is only called once when the
> attributes for a tag are the same (because it's reused), so how should
I
> go about developing the inner tag so the parent will always be set? I
> read up on SimpleTag and that could be the answer, but I'm worried
about
> performance with this because the writevalue tag is called many many
> times on one page.
> 
> Thanksk
> 
> -----Original Message-----
> From: Tim Funk [mailto:funkman@joedog.org] 
> Sent: Tuesday, September 07, 2004 7:59 AM
> To: Tomcat Users List
> Subject: Re: tag reuse, setParent and findAncestorWithClass
> 
> http://jakarta.apache.org/tomcat/faq/misc.html#tagbroken
> 
> -tim
> 
> Justin Kennedy wrote:
> 
>>Hi,
>>
>> 
>>
>>I'm upgrading our tag library to Tomcat 5 and having problems. Note
> 
> that
> 
>>they were written back in JSP 1.1 and haven't changed for a few years.
>>
>> 
>>
>>The problem looks like the tags are being cached and the setParent
> 
> isn't
> 
>>being called for each new "reuse". As a result the wrong tag is
> 
> returned
> 
>>from findAncestorWithClass when the WriteValueTag is re-used in a
>>different nested block. Maybe this is how the spec was designed and I
>>just don't know the right way to code the tags. Anyway here's what the
>>JSP page looks like (note: transacttag issues a call to the database.
>>Writevaluetag writes the value of a column from the data returned from
>>transacttag. If 'transactId' isn't passed to WriteValueTag, it will
> 
> use
> 
>>the findAncestorWithClass to find the enclosing IterateTag to
> 
> determine
> 
>>the transactId):
>>
>> 
>>
>><trans:transact id="uis" action="main_uis"/>
>>
>><logic:iterate transactId="uis" column="uiid">
>>
>>  <logic:equal value='<%=tmpuiid%>' column="uiid">
>>
>>    a - <trans:writeValue column="UI_NAME" /><br>
>>
>>    <trans:parameters id="params" scope="request">
>>
>>        <trans:addParameter parametersId="params" key="UIID"
> 
> value='<%=
> 
>>tmpuiid %>'/>
>>
>>    </trans:parameters>
>>
>>    <trans:transact id="ui" action="sub_uis" parametersId="params" /> 
>>
>>        <logic:exists transactId="ui" column="description">
>>
>>            <logic:iterate transactId="ui" column="ui_flowid">
>>
>>                #1 - <trans:writeValue column="UI_NAME" /><br>
>>
>>                #2 - <trans:writeValue transactId="ui"
>>column="FORM_NAME"/><br>
>>
>>                #3 - <trans:writeValue column="FORM_NAME"/><br>
>>
>>            </logic:iterate>
>>
>>        </logic:exists>
>>
>>  </logic:equal>
>>
>></logic:iterate>
>>
>> 
>>
>> 
>>
>>The problems:
>>
>>1.	UI_NAME in #1 is a column from the first "uis" transactTag. The
>>writeValueTag prints out the value of this column but it shouldn't
>>behave this way because it's enclosed IterateTag has a different
>>"transactId". I put this here to demonstrate the problem
>>2.	FORM_NAME in #3 is a column in the second transactTag of "ui".
>>This column value SHOULD be output (like it has always done) because
> 
> the
> 
>>enclosed iterateTag specifies the proper transactId, but this value is
>>not output because it's parent is set to the first IterateTag and not
>>the second, hence the different transactIds.
>>
>> 
>>
>>#2 works only because I'm explicitly setting the transactId. 
>>
>> 
>>
>>The WriteValueTag extends the TagSupport class and everything is done
> 
> in
> 
>>the doStartTag event.
>>

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




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


Re: tag reuse, setParent and findAncestorWithClass

Posted by Tim Funk <fu...@joedog.org>.
Turn off tag pooling.

-Tim

Justin Kennedy wrote:

> Hi Tim,
> 
> I read through the link you posted but I don't see any references to
> setParent. I understand that setParent is only called once when the
> attributes for a tag are the same (because it's reused), so how should I
> go about developing the inner tag so the parent will always be set? I
> read up on SimpleTag and that could be the answer, but I'm worried about
> performance with this because the writevalue tag is called many many
> times on one page.
> 
> Thanksk
> 
> -----Original Message-----
> From: Tim Funk [mailto:funkman@joedog.org] 
> Sent: Tuesday, September 07, 2004 7:59 AM
> To: Tomcat Users List
> Subject: Re: tag reuse, setParent and findAncestorWithClass
> 
> http://jakarta.apache.org/tomcat/faq/misc.html#tagbroken
> 
> -tim
> 
> Justin Kennedy wrote:
> 
>>Hi,
>>
>> 
>>
>>I'm upgrading our tag library to Tomcat 5 and having problems. Note
> 
> that
> 
>>they were written back in JSP 1.1 and haven't changed for a few years.
>>
>> 
>>
>>The problem looks like the tags are being cached and the setParent
> 
> isn't
> 
>>being called for each new "reuse". As a result the wrong tag is
> 
> returned
> 
>>from findAncestorWithClass when the WriteValueTag is re-used in a
>>different nested block. Maybe this is how the spec was designed and I
>>just don't know the right way to code the tags. Anyway here's what the
>>JSP page looks like (note: transacttag issues a call to the database.
>>Writevaluetag writes the value of a column from the data returned from
>>transacttag. If 'transactId' isn't passed to WriteValueTag, it will
> 
> use
> 
>>the findAncestorWithClass to find the enclosing IterateTag to
> 
> determine
> 
>>the transactId):
>>
>> 
>>
>><trans:transact id="uis" action="main_uis"/>
>>
>><logic:iterate transactId="uis" column="uiid">
>>
>>  <logic:equal value='<%=tmpuiid%>' column="uiid">
>>
>>    a - <trans:writeValue column="UI_NAME" /><br>
>>
>>    <trans:parameters id="params" scope="request">
>>
>>        <trans:addParameter parametersId="params" key="UIID"
> 
> value='<%=
> 
>>tmpuiid %>'/>
>>
>>    </trans:parameters>
>>
>>    <trans:transact id="ui" action="sub_uis" parametersId="params" /> 
>>
>>        <logic:exists transactId="ui" column="description">
>>
>>            <logic:iterate transactId="ui" column="ui_flowid">
>>
>>                #1 - <trans:writeValue column="UI_NAME" /><br>
>>
>>                #2 - <trans:writeValue transactId="ui"
>>column="FORM_NAME"/><br>
>>
>>                #3 - <trans:writeValue column="FORM_NAME"/><br>
>>
>>            </logic:iterate>
>>
>>        </logic:exists>
>>
>>  </logic:equal>
>>
>></logic:iterate>
>>
>> 
>>
>> 
>>
>>The problems:
>>
>>1.	UI_NAME in #1 is a column from the first "uis" transactTag. The
>>writeValueTag prints out the value of this column but it shouldn't
>>behave this way because it's enclosed IterateTag has a different
>>"transactId". I put this here to demonstrate the problem
>>2.	FORM_NAME in #3 is a column in the second transactTag of "ui".
>>This column value SHOULD be output (like it has always done) because
> 
> the
> 
>>enclosed iterateTag specifies the proper transactId, but this value is
>>not output because it's parent is set to the first IterateTag and not
>>the second, hence the different transactIds.
>>
>> 
>>
>>#2 works only because I'm explicitly setting the transactId. 
>>
>> 
>>
>>The WriteValueTag extends the TagSupport class and everything is done
> 
> in
> 
>>the doStartTag event.
>>

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


RE: tag reuse, setParent and findAncestorWithClass

Posted by Justin Kennedy <ju...@maritimesource.ca>.
Hi Tim,

I read through the link you posted but I don't see any references to
setParent. I understand that setParent is only called once when the
attributes for a tag are the same (because it's reused), so how should I
go about developing the inner tag so the parent will always be set? I
read up on SimpleTag and that could be the answer, but I'm worried about
performance with this because the writevalue tag is called many many
times on one page.

Thanksk

-----Original Message-----
From: Tim Funk [mailto:funkman@joedog.org] 
Sent: Tuesday, September 07, 2004 7:59 AM
To: Tomcat Users List
Subject: Re: tag reuse, setParent and findAncestorWithClass

http://jakarta.apache.org/tomcat/faq/misc.html#tagbroken

-tim

Justin Kennedy wrote:
> Hi,
> 
>  
> 
> I'm upgrading our tag library to Tomcat 5 and having problems. Note
that
> they were written back in JSP 1.1 and haven't changed for a few years.
> 
>  
> 
> The problem looks like the tags are being cached and the setParent
isn't
> being called for each new "reuse". As a result the wrong tag is
returned
> from findAncestorWithClass when the WriteValueTag is re-used in a
> different nested block. Maybe this is how the spec was designed and I
> just don't know the right way to code the tags. Anyway here's what the
> JSP page looks like (note: transacttag issues a call to the database.
> Writevaluetag writes the value of a column from the data returned from
> transacttag. If 'transactId' isn't passed to WriteValueTag, it will
use
> the findAncestorWithClass to find the enclosing IterateTag to
determine
> the transactId):
> 
>  
> 
> <trans:transact id="uis" action="main_uis"/>
> 
> <logic:iterate transactId="uis" column="uiid">
> 
>   <logic:equal value='<%=tmpuiid%>' column="uiid">
> 
>     a - <trans:writeValue column="UI_NAME" /><br>
> 
>     <trans:parameters id="params" scope="request">
> 
>         <trans:addParameter parametersId="params" key="UIID"
value='<%=
> tmpuiid %>'/>
> 
>     </trans:parameters>
> 
>     <trans:transact id="ui" action="sub_uis" parametersId="params" /> 
> 
>         <logic:exists transactId="ui" column="description">
> 
>             <logic:iterate transactId="ui" column="ui_flowid">
> 
>                 #1 - <trans:writeValue column="UI_NAME" /><br>
> 
>                 #2 - <trans:writeValue transactId="ui"
> column="FORM_NAME"/><br>
> 
>                 #3 - <trans:writeValue column="FORM_NAME"/><br>
> 
>             </logic:iterate>
> 
>         </logic:exists>
> 
>   </logic:equal>
> 
> </logic:iterate>
> 
>  
> 
>  
> 
> The problems:
> 
> 1.	UI_NAME in #1 is a column from the first "uis" transactTag. The
> writeValueTag prints out the value of this column but it shouldn't
> behave this way because it's enclosed IterateTag has a different
> "transactId". I put this here to demonstrate the problem
> 2.	FORM_NAME in #3 is a column in the second transactTag of "ui".
> This column value SHOULD be output (like it has always done) because
the
> enclosed iterateTag specifies the proper transactId, but this value is
> not output because it's parent is set to the first IterateTag and not
> the second, hence the different transactIds.
> 
>  
> 
> #2 works only because I'm explicitly setting the transactId. 
> 
>  
> 
> The WriteValueTag extends the TagSupport class and everything is done
in
> the doStartTag event.
> 
>  

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




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


Re: tag reuse, setParent and findAncestorWithClass

Posted by Tim Funk <fu...@joedog.org>.
http://jakarta.apache.org/tomcat/faq/misc.html#tagbroken

-tim

Justin Kennedy wrote:
> Hi,
> 
>  
> 
> I'm upgrading our tag library to Tomcat 5 and having problems. Note that
> they were written back in JSP 1.1 and haven't changed for a few years.
> 
>  
> 
> The problem looks like the tags are being cached and the setParent isn't
> being called for each new "reuse". As a result the wrong tag is returned
> from findAncestorWithClass when the WriteValueTag is re-used in a
> different nested block. Maybe this is how the spec was designed and I
> just don't know the right way to code the tags. Anyway here's what the
> JSP page looks like (note: transacttag issues a call to the database.
> Writevaluetag writes the value of a column from the data returned from
> transacttag. If 'transactId' isn't passed to WriteValueTag, it will use
> the findAncestorWithClass to find the enclosing IterateTag to determine
> the transactId):
> 
>  
> 
> <trans:transact id="uis" action="main_uis"/>
> 
> <logic:iterate transactId="uis" column="uiid">
> 
>   <logic:equal value='<%=tmpuiid%>' column="uiid">
> 
>     a - <trans:writeValue column="UI_NAME" /><br>
> 
>     <trans:parameters id="params" scope="request">
> 
>         <trans:addParameter parametersId="params" key="UIID" value='<%=
> tmpuiid %>'/>
> 
>     </trans:parameters>
> 
>     <trans:transact id="ui" action="sub_uis" parametersId="params" /> 
> 
>         <logic:exists transactId="ui" column="description">
> 
>             <logic:iterate transactId="ui" column="ui_flowid">
> 
>                 #1 - <trans:writeValue column="UI_NAME" /><br>
> 
>                 #2 - <trans:writeValue transactId="ui"
> column="FORM_NAME"/><br>
> 
>                 #3 - <trans:writeValue column="FORM_NAME"/><br>
> 
>             </logic:iterate>
> 
>         </logic:exists>
> 
>   </logic:equal>
> 
> </logic:iterate>
> 
>  
> 
>  
> 
> The problems:
> 
> 1.	UI_NAME in #1 is a column from the first "uis" transactTag. The
> writeValueTag prints out the value of this column but it shouldn't
> behave this way because it's enclosed IterateTag has a different
> "transactId". I put this here to demonstrate the problem
> 2.	FORM_NAME in #3 is a column in the second transactTag of "ui".
> This column value SHOULD be output (like it has always done) because the
> enclosed iterateTag specifies the proper transactId, but this value is
> not output because it's parent is set to the first IterateTag and not
> the second, hence the different transactIds.
> 
>  
> 
> #2 works only because I'm explicitly setting the transactId. 
> 
>  
> 
> The WriteValueTag extends the TagSupport class and everything is done in
> the doStartTag event.
> 
>  

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