I'm running into something that I can't figure out.  Many moons ago, I
wrote an Iterate tag that simply looped through a collection and
evaluated the body of the tag.  It was very simple and straightforward,
as was my use of it.
The tag has worked fine for several years now and is used extensively
in a large web app.
However, when I move the app from Tomcat 4.1.24 to Tomcat 5.5.9, it
breaks.  I keep getting this error.

SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: jsp.error.beans.property.conversion
        at
org.apache.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager(JspRuntimeLibrary.java:885)
        at
org.apache.jsp.tkarchive_jsp._jspService(tkarchive_jsp.java:90)


This appears to be a runtime casting/conversion error, but I'm having
trouble tracking it down.  I'm assuming something has changed in tag
handling between the versions of Tomcat.

A simple JSP use of the tag would be as follows:

<boa:iterate collection='debugs' iteratedItemName='item'
iteratedItemClass='java.lang.String'>
Debug:&nbsp;&nbsp;&nbsp; <%=item.toString()%><br>
</boa:iterate>

In this example, I have a Vector in the session and it holds a series
of Strings that I use to collect debuging info.  This tag loops through
them and prints their contents to the page.

The Source for the tag itself is here:

/*
 * IterateTag.java
 *
 * Created on October 7, 2002, 2:43 PM
 */

package boa;

import javax.servlet.jsp.tagext.*;
import javax.servlet.jsp.*;
import javax.servlet.*;
import java.io.Writer;
import java.util.*;
import java.io.IOException;
import java.lang.reflect.*;
import java.sql.*;



public class IterateTag extends javax.servlet.jsp.tagext.BodyTagSupport
{

    private Object collectionBean;
    private Iterator iterator;
    private String iteratedItemName;
    private String iteratedItemClass;
    private Collection _collection;

    /** Creates new IterateTag */
    public IterateTag() {
    }


    public int doStartTag() throws JspTagException
    {
        if(_collection==null)
        {
         throw new JspTagException("No collection with name
"+_collection+" found");
        }
        iterator=_collection.iterator();
        if(iterator.hasNext())
        {
            pageContext.setAttribute("item",iterator.next());
            return this.EVAL_BODY_INCLUDE;
        }
        else
        {
            return this.SKIP_BODY;
        }
    }

    public int doAfterBody()
    {
        if(iterator.hasNext())
        {
            pageContext.setAttribute("item",iterator.next());
            return this.EVAL_BODY_AGAIN;
        }
        else
        {
            return this.SKIP_BODY;
        }
    }

    public void setCollection(String namedcollection){

//this._collection=(Collection)this.pageContext.getAttribute(namedcollection);


this._collection=(Collection)this.pageContext.getSession().getAttribute(namedcollection);
    }

     public void setCollection(Collection collection) {
       this._collection= collection;

    }

    public void setIteratedItemClass(String newIteratedItemClass) {
       iteratedItemClass = newIteratedItemClass;
    }

    public void setIteratedItemName(String newIteratedItemName) {
        iteratedItemName=newIteratedItemName;
    }

}

The Source for the IterateTEI code is here:

/*
 * IterateTEI.java
 *
 * Created on October 7, 2002, 3:02 PM
 */

package boa;

import java.util.*;
import javax.servlet.jsp.tagext.*;

public class IterateTEI extends TagExtraInfo {

    public VariableInfo[] getVariableInfo(TagData tagData)
    {
     String
objectType=tagData.getAttributeString("iteratedItemClass");
     if(objectType == null)
         objectType = "java.lang.Object";
     return new VariableInfo[]{
         new VariableInfo(
            tagData.getAttributeString("iteratedItemName"),
            objectType,
            true,
            VariableInfo.NESTED)
     };
    }
}

If anyone has any insight into this, I would greatly appreciate it.  As
I said, it still works under Tomcat 4.1.24.  There's enough instances of
this tag in use, that changing to another Iterate tag from a different
library would be prohibitively time consuming.

Thanks.

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to