I just set up Tomcat 4.1.18 with my tag library I had been using with Tomcat
4.0.4.  The tags don't work anymore.

The set up is like this:
<tag1 name="name">
    <tag2 name="name">value</tag2>
    <tag2 name="name" value="value"/>
</tag1>

tag2 sets parameters in tag1, which then executes a SQL query.


tag1 looks like this:
Public class tag1 extends BodyTagSupport
{
    private String name;
    private String param = "";

    public void setName (String name) { this.name = name; }

    public void setParam (String param)
    {
        if (this.param.equals("")) this.param = param;
        else this.param = ", " + param;
    }
    
    public int doStartTag() { return EVAL_BODY_BUFFERED; }
    public int doAfterBody()
    {
        stmt.execute(param);
        // obviously not a complete program but you get the idea
        return EVAL_PAGE;
    }
}

tag2 looks like this:
Public class tag2 extends BodyTagSupport
{
    private String name = "";
    private String value = "";

    public void setName (String name) { this.name = name; }
    public void setValue (String value) { this.value = value; }

    public int doStartTag() { return EVAL_BODY_BUFFERED; }
    public int doAfterBody()
    {
        BodyContent body = getBodyContent()
        tag1Parent = (tag1)findAncestorWithClass(this, tag1.class);

        if (value != "")
        {
            tag1Parent.setParam(value);
        }
        else
        {
            tag1Parent.setParam("'" + value + "'");
        }
        // again not a complete program, but hopefully the idea is clear
        return EVAL_PAGE;
    }
}


Under Tomcat 4.1.18, the second tag2 doesn't seem to remember the value
string once it gets to doAfterBody.  It sets it correctly in setValue(), but
in doAfterBody() it acts like value is an empty string.  The first tag2
(which has a body) works fine.  Both worked fine under Tomcat 4.0.4.

Also, the param string in tag1 keeps accumulating values from the first tag2
every time I reload the page.  Under Tomcat 4.0.4, it started out with an
empty string when I refreshed.

Did something change between Tomcats 4.0 and 4.1 in the way tags are
handled?  Do I need to rewrite my code?  Was my code wrong in the first
place, or is Tomcat 4.1 buggy?  Please help.

Thanks,
Ben Carterette
[EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to