?
Solved

Class Cast Exception while finding all the session attributes

Posted on 2009-04-20
1
Medium Priority
?
437 Views
Last Modified: 2013-11-24
Hi,
I am using struts version 1.2.9 and am trying to get all the session variables to check for all the value with the following piece of code but am getting a class cast exception with it.
Any idea why this is happening ?
      java.util.Enumeration allParameter = session.getAttributeNames();          
          if (null!=allParameter)
          {  
              while(allParameter.hasMoreElements())
              {

                   String attribValue=(String)session.getAttribute(allParameter.nextElement().toString());

              }
          }
       
          }
0
Comment
Question by:pradumb29
1 Comment
 
LVL 20

Accepted Solution

by:
Venabili earned 150 total points
ID: 24192539
Can you post the full stacktrace? And try this instead of your example : (it;s different in where you cast and where you call a method)
session.getAttribute((String)allParameter.nextElement()).toString(); 

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question