Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFSJ - Page 87 - result.jsp

 
Giri Gopalan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
 
Moojid Hamid
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic