• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 440
  • Last Modified:

Class Cast Exception while finding all the session attributes

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
pradumb29
Asked:
pradumb29
1 Solution
 
VenabiliCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now