TreeMap isn't a Collection but a Map. You can't cast it into a Collection !
If you really want a collection from a TreeMap, you have to choice either the keySet or the entrySet of the TreeMap. fv -----Message d'origine----- De : Todd G. Nist [mailto:[EMAIL PROTECTED]] Envoy� : jeudi 6 d�cembre 2001 13:58 � : [EMAIL PROTECTED] Objet : CachedRowSet - how to convert to a collection with the "toCollect ion()" method Hello, I must be missing something simple here, but here is the question. I have a servlet which is generating a CachedRowSet for holding the data for processing by a JSP. The jsp is using the struts tags, specifically, the "logic:iterator" tag which requires a Collection of one of the following types: array, java.util.Collection, ArrayList, Vector, juaa.util.Enumeration, iterator, HashMap, Hastable or TreeMap. There is a tag on the CachedRowSet called "toCollection()" which according to the documentation returns a "java.util.Collection". When ever I try to convert it to a collection with the above method, I receive the following error: java.lang.ClassCastException: java.util.TreeMap at sun.jdbc.rowset.CachedRowSet.toCollection(CachedRowSet.java:1057) The basic code fragment which throws the exception looks like this: Collection myCollection = null; CachedRowSet crs = null; // do necessary setup and obtain valid CachedRowSet; try{ crs.execute(getCon()); crs.first(); myCollection = crs.toCollection(); } . . . So the question is how to I manage to convert the CachedRowSet to one of the above collections. Regards, Todd G. Nist Email: [EMAIL PROTECTED] ___________________________________________________________________________ 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 ------------------------------------------------------------- This Message and any attachments are confidential and intended solely for the addressees. And unauthorised use or dissemination are prohibited. Emails are suceptible to alteration. Therefore neither SWAPCOM nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified. ___________________________________________________________________________ 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
