Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
Custom Iterate Tag Breaks under new Tomcat

Custom Iterate Tag Breaks under new Tomcat

2006-03-22       - By Jason Johnston

 Back
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 listserv@(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

©2008 junlu.com - Jax Systems, LLC, U.S.A.