Class Cast Exception while finding all the session attributes

Posted on 2009-04-20
Last Modified: 2013-11-24
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)

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

Question by:pradumb29
    1 Comment
    LVL 20

    Accepted Solution

    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)

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Title # Comments Views Activity
    fizzArray  challenge 1 28
    instanceof  operator in java 26 54
    noX challenge 17 52
    json format text only 4 48
    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 …
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    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.

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now