users@glassfish.java.net

Re: Glassfish JSTL implementation object releasing problem ?

From: <glassfish_at_javadesktop.org>
Date: Sun, 22 Jun 2008 09:11:57 PDT

Another thought is that you can use a simple wrapper for your heavyweight objects.

[code]
public class Wrapper {
    public BigThing bigThing;
    public OtherBigThing otherBigThing;

    // ... setters and getters ellided
    public String getClear() {
        bigThing = null;
        otherBigThing == null;
        return null;
    }
}
[/code]

Then in your JSP, just reference your wrapper (${wrapper.bigThing}).

And finally, at the end of the JSP, do ${wrapper.clear}, which will "print nothing", but zap your variables for GC.

The tags hold on to the wrapper, but so what.

And you use the "hack" of getClear so you can use EL to clear the objects, rather than having to resort to scriptlets.
[Message sent by forum member 'whartung' (whartung)]

http://forums.java.net/jive/thread.jspa?messageID=281854