|
|
|
Yes, you're probably right. I had just assumed that the attrubute setters were called after the doStartTag()-method, but that does not seem to be the case.
What if we clear the groups-variable in the doEndTag()-method instead? I doesn't have any knowledge about the jsp spec, but shouldn't the values resetted in doFinally() ?
And what about the values key, cron, time etc.? Where did you find something about the "correct" behaviour for so called "classic tags"? Again, yes, the doFinally() method is probably even better than the
doEndTag()-method. (Although I think it's strange if there is no method equivalent to a counstructor where one could reset the object's state _before_ the setters are called...). And yes (again), perhaps/probably also some other instance variables such as key, cron, time, should be reset there... About "correct" usage, I just tried to point out that instances of the tag-objects may be reused. Someone at work handed me the book "Pro JSP" by Simon Brown et. al. where they said (pp 222) "... with containes that provide instance pooling, [the release()] method is only called when the container has finished using the instance and before it gets garbage collected". Btw, on pp 276 in that book there is a graph showing how the doStartTag, doEndTag and doFinally are called relative to each other. doFinally is the right approach, but it is part of JSP 1.2 and not 1.1. However, since we already have a doFinally, might as well add the clearing of all local state there (this isn't just about the groups field, but all the others too).
We should reset (null) the following states in doFinally:
- groups - scope (PageContext.APPLICATION_SCOPE) - cron - key - language - refreshpolicyclass - refreshpolicyparam - time (DEFAULT_TIMEOUT) - refresh (false) - mode (0) The oscache.tld references jsp version 1.2 already. | |||||||||||||||||||||||||||||||||||||||
groups = null;
to the beginning of CacheTag.doStartTag() and the page contains
<cache:cache key="<%= product.getId() %>" time="-1" group="currencyData, categories">
doesn't the groups information are cleared, because the groups information is passed to the Tag object through setter method calls, prior to the call to doStartTag()?