You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Bill Clinton <bc...@snipermail.com> on 2001/09/06 01:28:51 UTC

Re: Concurrency and Custom JSP tags

Erik -
     Thanks for clearing that up.  I will be sure to recheck my release 
methods.  It is a relief to know that there is nothing to worry about 
here (as long as the resources are cleared).

Thanks,
Bill

Erik Hatcher wrote:

>Quoting from Geary's Advanced JavaServer Pages book, p. 14:
>
>"Because servlet containers can reuse tag handlers, you must be diligent
>about implementing the release method and careful about instantiating
>resources in doStartTag [rather in the tags constructor]"
>
>So the 'release' method is the key.   You'll notice that the Struts tags use
>the release method to clear their resources.   Tag instances are not used
>simultaneously, but released for re-use after they are done, so member
>variables are ok, but care must be taken not to allow them to carry over to
>future uses.
>
>I highly recommend Geary's book for all Struts power users and developers,
>especially in regards to custom tag development.
>
>    Erik
>
>
>----- Original Message -----
>From: "Bill Clinton" <bc...@snipermail.com>
>To: "struts" <st...@jakarta.apache.org>
>Sent: Wednesday, September 05, 2001 3:42 PM
>Subject: Concurrency and Custom JSP tags
>
>
>>Hello,
>>     I have been writing my own custom jsp tags, and have recently
>>noticed that member properties of tags seem to be retained after the tag
>>is complete.
>>
>>     For example, lets say you have a tag that has an optional attribute
>>called "message", and the tag is designed to print this attribute if it
>>is passed.  If you call this tag and pass "hello" as the attribute
>>message on one page, then call this tag on another page without passing
>>the attribute, it will still be set to "hello".
>>
>>     This functions much like a servlet, which is multi-threaded but
>>retains the values for member variables across different requests.  I
>>think most servlet programmers realize this and stay away from using
>>non-static member variables.  But it seems to me that custom JSP tag
>>design encourages the use of attributes, which seems to be potentially
>>very dangerous in an environment with a high volume of requests.
>>
>>     I would like to know if anyone knows of any good links where
>>concurrency issues in custom jsp tags are discussed more in depth.
>> Also, I am curious to know if anyone has encountered any problems like
>>this with the Struts tags.  For example, if I set an "onmouseover" for a
>><html:checkbox> tag, do I have to worry about this attribute showing up
>>in a <html:checkbox>  tag called from a different page if both pages are
>>loaded by different users at the same time?
>>
>>Thanks in advance for any info,
>>Bill
>>
>
>
>.
>



Re: Concurrency and Custom JSP tags

Posted by Erik Hatcher <er...@earthlink.net>.
Good stuff.   Thanks Mac for a clearer picture on this.   So I'm assuming
Geary's book isn't quite accurate on this topic then, no?

    Erik

----- Original Message -----
From: "Mac Ferguson" <mf...@communicopia.com>
To: <st...@jakarta.apache.org>
Sent: Thursday, September 06, 2001 6:38 AM
Subject: RE: Concurrency and Custom JSP tags


> Actually, release() is only guaranteed to be called before the handler is
> GC'ed (JSP1.2 specification p.166), and is intended to release any
> heavyweight resources the handler may have acquired. Also from page 165
> (describing the )"[1]this transition is intended to be for releasing
> long-term data. no guarantees are assumed on whether any properties have
> been retained or not." Here's a link to a discussion on the taglibs-dev
> maillist that was very educational for me...
> http://www.mail-archive.com/taglibs-dev@jakarta.apache.org/msg00846.html
>
>
> -----Original Message-----
> From: Bill Clinton [mailto:bclinton@snipermail.com]
> Sent: Wednesday, September 05, 2001 7:29 PM
> To: struts-user@jakarta.apache.org
> Subject: Re: Concurrency and Custom JSP tags
>
>
> Erik -
>      Thanks for clearing that up.  I will be sure to recheck my release
> methods.  It is a relief to know that there is nothing to worry about
> here (as long as the resources are cleared).
>
> Thanks,
> Bill
>
> Erik Hatcher wrote:
>
> >Quoting from Geary's Advanced JavaServer Pages book, p. 14:
> >
> >"Because servlet containers can reuse tag handlers, you must be diligent
> >about implementing the release method and careful about instantiating
> >resources in doStartTag [rather in the tags constructor]"
> >
> >So the 'release' method is the key.   You'll notice that the Struts tags
> use
> >the release method to clear their resources.   Tag instances are not used
> >simultaneously, but released for re-use after they are done, so member
> >variables are ok, but care must be taken not to allow them to carry over
to
> >future uses.
> >
> >I highly recommend Geary's book for all Struts power users and
developers,
> >especially in regards to custom tag development.
> >
> >    Erik
> >
> >
> >----- Original Message -----
> >From: "Bill Clinton" <bc...@snipermail.com>
> >To: "struts" <st...@jakarta.apache.org>
> >Sent: Wednesday, September 05, 2001 3:42 PM
> >Subject: Concurrency and Custom JSP tags
> >
> >
> >>Hello,
> >>     I have been writing my own custom jsp tags, and have recently
> >>noticed that member properties of tags seem to be retained after the tag
> >>is complete.
> >>
> >>     For example, lets say you have a tag that has an optional attribute
> >>called "message", and the tag is designed to print this attribute if it
> >>is passed.  If you call this tag and pass "hello" as the attribute
> >>message on one page, then call this tag on another page without passing
> >>the attribute, it will still be set to "hello".
> >>
> >>     This functions much like a servlet, which is multi-threaded but
> >>retains the values for member variables across different requests.  I
> >>think most servlet programmers realize this and stay away from using
> >>non-static member variables.  But it seems to me that custom JSP tag
> >>design encourages the use of attributes, which seems to be potentially
> >>very dangerous in an environment with a high volume of requests.
> >>
> >>     I would like to know if anyone knows of any good links where
> >>concurrency issues in custom jsp tags are discussed more in depth.
> >> Also, I am curious to know if anyone has encountered any problems like
> >>this with the Struts tags.  For example, if I set an "onmouseover" for a
> >><html:checkbox> tag, do I have to worry about this attribute showing up
> >>in a <html:checkbox>  tag called from a different page if both pages are
> >>loaded by different users at the same time?
> >>
> >>Thanks in advance for any info,
> >>Bill
> >>
> >
> >
> >.
> >
>
>
>


Re: Concurrency and Custom JSP tags

Posted by Bill Clinton <bc...@snipermail.com>.
Thanks alot Mac,
     A very good thread.

Bill

Mac Ferguson wrote:

>Actually, release() is only guaranteed to be called before the handler is
>GC'ed (JSP1.2 specification p.166), and is intended to release any
>heavyweight resources the handler may have acquired. Also from page 165
>(describing the )"[1]this transition is intended to be for releasing
>long-term data. no guarantees are assumed on whether any properties have
>been retained or not." Here's a link to a discussion on the taglibs-dev
>maillist that was very educational for me...
>http://www.mail-archive.com/taglibs-dev@jakarta.apache.org/msg00846.html
>
>
>-----Original Message-----
>From: Bill Clinton [mailto:bclinton@snipermail.com]
>Sent: Wednesday, September 05, 2001 7:29 PM
>To: struts-user@jakarta.apache.org
>Subject: Re: Concurrency and Custom JSP tags
>
>
>Erik -
>     Thanks for clearing that up.  I will be sure to recheck my release
>methods.  It is a relief to know that there is nothing to worry about
>here (as long as the resources are cleared).
>
>Thanks,
>Bill
>
>Erik Hatcher wrote:
>
>>Quoting from Geary's Advanced JavaServer Pages book, p. 14:
>>
>>"Because servlet containers can reuse tag handlers, you must be diligent
>>about implementing the release method and careful about instantiating
>>resources in doStartTag [rather in the tags constructor]"
>>
>>So the 'release' method is the key.   You'll notice that the Struts tags
>>
>use
>
>>the release method to clear their resources.   Tag instances are not used
>>simultaneously, but released for re-use after they are done, so member
>>variables are ok, but care must be taken not to allow them to carry over to
>>future uses.
>>
>>I highly recommend Geary's book for all Struts power users and developers,
>>especially in regards to custom tag development.
>>
>>   Erik
>>
>>
>>----- Original Message -----
>>From: "Bill Clinton" <bc...@snipermail.com>
>>To: "struts" <st...@jakarta.apache.org>
>>Sent: Wednesday, September 05, 2001 3:42 PM
>>Subject: Concurrency and Custom JSP tags
>>
>>
>>>Hello,
>>>    I have been writing my own custom jsp tags, and have recently
>>>noticed that member properties of tags seem to be retained after the tag
>>>is complete.
>>>
>>>    For example, lets say you have a tag that has an optional attribute
>>>called "message", and the tag is designed to print this attribute if it
>>>is passed.  If you call this tag and pass "hello" as the attribute
>>>message on one page, then call this tag on another page without passing
>>>the attribute, it will still be set to "hello".
>>>
>>>    This functions much like a servlet, which is multi-threaded but
>>>retains the values for member variables across different requests.  I
>>>think most servlet programmers realize this and stay away from using
>>>non-static member variables.  But it seems to me that custom JSP tag
>>>design encourages the use of attributes, which seems to be potentially
>>>very dangerous in an environment with a high volume of requests.
>>>
>>>    I would like to know if anyone knows of any good links where
>>>concurrency issues in custom jsp tags are discussed more in depth.
>>>Also, I am curious to know if anyone has encountered any problems like
>>>this with the Struts tags.  For example, if I set an "onmouseover" for a
>>><html:checkbox> tag, do I have to worry about this attribute showing up
>>>in a <html:checkbox>  tag called from a different page if both pages are
>>>loaded by different users at the same time?
>>>
>>>Thanks in advance for any info,
>>>Bill
>>>
>>
>>.
>>
>
>
>
>
>.
>



RE: Concurrency and Custom JSP tags

Posted by Mac Ferguson <mf...@communicopia.com>.
Actually, release() is only guaranteed to be called before the handler is
GC'ed (JSP1.2 specification p.166), and is intended to release any
heavyweight resources the handler may have acquired. Also from page 165
(describing the )"[1]this transition is intended to be for releasing
long-term data. no guarantees are assumed on whether any properties have
been retained or not." Here's a link to a discussion on the taglibs-dev
maillist that was very educational for me...
http://www.mail-archive.com/taglibs-dev@jakarta.apache.org/msg00846.html


-----Original Message-----
From: Bill Clinton [mailto:bclinton@snipermail.com]
Sent: Wednesday, September 05, 2001 7:29 PM
To: struts-user@jakarta.apache.org
Subject: Re: Concurrency and Custom JSP tags


Erik -
     Thanks for clearing that up.  I will be sure to recheck my release
methods.  It is a relief to know that there is nothing to worry about
here (as long as the resources are cleared).

Thanks,
Bill

Erik Hatcher wrote:

>Quoting from Geary's Advanced JavaServer Pages book, p. 14:
>
>"Because servlet containers can reuse tag handlers, you must be diligent
>about implementing the release method and careful about instantiating
>resources in doStartTag [rather in the tags constructor]"
>
>So the 'release' method is the key.   You'll notice that the Struts tags
use
>the release method to clear their resources.   Tag instances are not used
>simultaneously, but released for re-use after they are done, so member
>variables are ok, but care must be taken not to allow them to carry over to
>future uses.
>
>I highly recommend Geary's book for all Struts power users and developers,
>especially in regards to custom tag development.
>
>    Erik
>
>
>----- Original Message -----
>From: "Bill Clinton" <bc...@snipermail.com>
>To: "struts" <st...@jakarta.apache.org>
>Sent: Wednesday, September 05, 2001 3:42 PM
>Subject: Concurrency and Custom JSP tags
>
>
>>Hello,
>>     I have been writing my own custom jsp tags, and have recently
>>noticed that member properties of tags seem to be retained after the tag
>>is complete.
>>
>>     For example, lets say you have a tag that has an optional attribute
>>called "message", and the tag is designed to print this attribute if it
>>is passed.  If you call this tag and pass "hello" as the attribute
>>message on one page, then call this tag on another page without passing
>>the attribute, it will still be set to "hello".
>>
>>     This functions much like a servlet, which is multi-threaded but
>>retains the values for member variables across different requests.  I
>>think most servlet programmers realize this and stay away from using
>>non-static member variables.  But it seems to me that custom JSP tag
>>design encourages the use of attributes, which seems to be potentially
>>very dangerous in an environment with a high volume of requests.
>>
>>     I would like to know if anyone knows of any good links where
>>concurrency issues in custom jsp tags are discussed more in depth.
>> Also, I am curious to know if anyone has encountered any problems like
>>this with the Struts tags.  For example, if I set an "onmouseover" for a
>><html:checkbox> tag, do I have to worry about this attribute showing up
>>in a <html:checkbox>  tag called from a different page if both pages are
>>loaded by different users at the same time?
>>
>>Thanks in advance for any info,
>>Bill
>>
>
>
>.
>