File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tag library - release method() never gets called

 
Johnny O'Boylan
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written a tag and it seems that Tomcat 4.1 pools tag librarys, whereas Tomcat 4.0, creates a new instance every time.
  • Shouldn't the release() method of the tag be automatically called before subsequent requests?
  • Why does the release method only get called before the container recompiles the JSP (where the tag is requested)?

  • Can someone please tell me why this happens ( in 2.3 and/or 2.2 spec)?
     
    Simon Brown
    sharp shooter, and author
    Ranch Hand
    Posts: 1913
    6
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    It's a common misconception that the release() method of a tag handler gets called before every invocation of a tag - whether it is reused or not. This is not true. The release() method is called when the JSP container has finished using the tag.
    So, what this means for containers that don't reuse instances is that release() gets called after they have performed their processing since that instance will never be used again. For containers that do reuse tag handler instances, release() will only get called when the container has finished using the tag - i.e. sometime before the instance get's garbage collected, before the reference gets "forgotten".
    In your case, you'll probably find that the container dumps the tag handler instances whenever the JSP translation process takes place to be on the safe side, as the rules around how tags can be reused are fairly complex. Hence release() is being called.
    HTH
    Simon
     
    Simon Brown
    sharp shooter, and author
    Ranch Hand
    Posts: 1913
    6
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Incidently, JSP 2.0 addresses this complexity by introducing a new mechanism for building custom tags - the SimpleTag interface. Tags built this way are not subject to these complex rules.
    Simon
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic