File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Tag library - release method() never gets called Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Tag library - release method() never gets called" Watch "Tag library - release method() never gets called" New topic
Author

Tag library - release method() never gets called

Johnny O'Boylan
Greenhorn

Joined: Feb 07, 2002
Posts: 21
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)?


    ==================================<br />If you choose not to decide,<br />you still have made a choice.<br />==================================
    Simon Brown
    sharp shooter, and author
    Ranch Hand

    Joined: May 10, 2000
    Posts: 1913
        
        6
    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

    Joined: May 10, 2000
    Posts: 1913
        
        6
    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.
     
    subject: Tag library - release method() never gets called
     
    Similar Threads
    HFSJ - Custom Tag Development - Question 12 (Page 564)
    JSP tags retaining previous data
    HF Chapter 10, Q12 question
    why jboss is not calling realease() in taglibs
    Tag Handler confusion