views:

42

answers:

2

I have a problem where certain attributes in tag files stick around for the next time the tag is used.

I think this is because the Tag class is being classloaded, and then that same instance is reused for every invocation. So attributes that i do not set in later invocations are not null like i would expect them to be, and contain stale values!

I want this to not happen any more. Does anyone know what setting controls that in tomcat 6?

+1  A: 

In fact, only one tag instance is been created everytime. Maybe you declared the attributes static?

BalusC
no, i did not do such a crazy thing =)
mkoryak
+2  A: 

You need to clear the state of the tag between the calls. You should do that in the doEndTag() method of your class, just before returning. At that point you should set all the state variables to null.

Roland Illig
can you point me to a javadoc or something that says i need to do this? it seems a little crazy that this is the norm rather then the exception
mkoryak
One thing I found is implementation-specific to Apache Tomcat, but anyway, here it is: http://tomcat.apache.org/tomcat-5.5-doc/jasper-howto.html
Roland Illig
Roland, you might be on the right track here. ill try that setting and see if it fixes things
mkoryak