GeeCON Prague 2014*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes passing Enumeration as an Attribute from servlet to jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "passing Enumeration as an Attribute from servlet to jsp" Watch "passing Enumeration as an Attribute from servlet to jsp" New topic
Author

passing Enumeration as an Attribute from servlet to jsp

Varun Nayudu
Ranch Hand

Joined: Jun 26, 2006
Posts: 157
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


SCJP 1.5, SCWCD 1.5
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

1. How did you redirect from your servlet to your JSP ?
2. Which package did you import in your jsp ? (java.util.* ?)


[My Blog]
All roads lead to JavaRanch
Varun Nayudu
Ranch Hand

Joined: Jun 26, 2006
Posts: 157
i imported java.util.* in my jsp
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Please post the complete exception stack trace.
 
GeeCON Prague 2014
 
subject: passing Enumeration as an Attribute from servlet to jsp