• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing Enumeration as an Attribute from servlet to jsp

 
Varun Nayudu
Ranch Hand
Posts: 159
  • 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
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 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: 159
  • 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 Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post the complete exception stack trace.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic