David--

Personally...I would use reflection...
try
{
List<MyType> var = Class.forName(request.getAttribute(name));// get class definitions o = var.newInstance(); //Instantiate a new class using the class(and consequent definitions)..
}
catch(Exception excp)
{
System.out.println("Didnt like the class ..message="+exp.getMessage());
}

HTH,
Martin --
*********************************************************************
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.


Martin Gainty

______________________________________________
Disclaimer and confidentiality note
Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission.
(mobile) 001-603-438-5053





From: David Wall <[EMAIL PROTECTED]>
Reply-To: "Tomcat Users List" <users@tomcat.apache.org>
To: Tomcat Users List <users@tomcat.apache.org>
Subject: Retrieving List<MyType> from a request/session attribute
Date: Thu, 22 Jun 2006 11:19:07 -0700
MIME-Version: 1.0
Received: from mail.apache.org ([209.237.227.199]) by bay0-mc6-f19.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2444); Thu, 22 Jun 2006 11:19:31 -0700
Received: (qmail 80771 invoked by uid 500); 22 Jun 2006 18:19:17 -0000
Received: (qmail 80760 invoked by uid 99); 22 Jun 2006 18:19:17 -0000
Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Jun 2006 11:19:17 -0700
Received: neutral (asf.osuosl.org: local policy)
Received: from [63.251.168.97] (HELO mail2.yozons.com) (63.251.168.97) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Jun 2006 11:19:16 -0700 Received: from [192.168.1.46] (pool-71-112-28-61.sttlwa.dsl-w.verizon.net [71.112.28.61])(authenticated bits=0)by mail2.yozons.com (8.12.10/8.12.10) with ESMTP id k5MIIsxs013014(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)for <users@tomcat.apache.org>; Thu, 22 Jun 2006 11:18:55 -0700
X-Message-Info: LsUYwwHHNt0oyiK71XSmxCHgd7F3k8W+/lR8NPWdBTc=
Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
Precedence: bulk
List-Help: <mailto:[EMAIL PROTECTED]>
List-Unsubscribe: <mailto:[EMAIL PROTECTED]>
List-Post: <mailto:users@tomcat.apache.org>
List-Id: <users.tomcat.apache.org>
Delivered-To: mailing list users@tomcat.apache.org
X-ASF-Spam-Status: No, hits=0.5 required=10.0tests=DNS_FROM_RFC_ABUSE
X-Spam-Check-By: apache.org
User-Agent: Thunderbird 1.5.0.4 (Windows/20060516)
X-Virus-Checked: Checked by ClamAV on apache.org
Return-Path: [EMAIL PROTECTED]
X-OriginalArrivalTime: 22 Jun 2006 18:19:32.0266 (UTC) FILETIME=[687F28A0:01C69628]

Is there a correct way to retrieve a typed List from a request/session attribute? The attribute is returned as an Object, but using a cast like:

List<MyType> var = (List<MyType>)request.getAttribute(name);

results in a warning:

Type safety: The cast from Object to List<MyType> is actually checking against the erased type List

The code works fine, but I'd like to get rid of the warning if there's a correct way to do this cast.

Thanks,
David

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to