Win a copy of Spark in Action this week in the Open Source Projects forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

passing Enumeration as an Attribute from servlet to jsp

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

i want to pass an Enumeration from a servlet to an Jsp through an Attribute, but am facing problems in the getAttribute() method even after casting it into an Enumeration
Here is the code....

Servlet code....
Enumeration En = getServletConfig().getInitParameterNames();
request.setAttribute("enu",En);

JSP code....
Enumeration en = (Enumeration)request.getAttribute("enu");
while(en.hasMoreElements()){
String i = (String)en.nextElement();
}

Please guide me what is wrong in the code since its giving classCastException
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. How did you redirect from your servlet to your JSP ?
2. Which package did you import in your jsp ? (java.util.* ?)
 
Varun Nayudu
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i imported java.util.* in my jsp
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post the complete exception stack trace.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic