• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HFSJ - Page 87 - result.jsp

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All

I have just worked out the Beer selection example from the book. I compiled the relevant classes (BeerExpert and BeerSelect) in JDK1.5 environment (book recommends 1.5 or above) and Tomcat 5.5. When I submit form1.html, there is a JSP compilation error on result.jsp. I know that it could be to do with Generic types, but I have set-up the environment as per the recommendation in the book. I would much appreciate you can help me to resolve the issue. Please find the error message below:


org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 9 in the jsp file: /result.jsp
Type mismatch: cannot convert from Object to List
6: <p>
7:
8: <%
9: List styles = request.getAttribute("styles");
10: Iterator it = styles.iterator();
11: /*for (String s : styles) {
12: out.print("<br> try:"+s);


Thanks
Giri
 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
request.getAttribute() returns Object, you need to cast it to List.
 
Giri Gopalan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Moojid

Thanks. It works now. I had mistakenly removed the type cast when trying out the same example in 1.6

Cheers
Giri
reply
    Bookmark Topic Watch Topic
  • New Topic