Newbie to jsp/tomcat/servlets..
I was able to compile the following in my tomcat5.5 installation(
java version in use is jdk1.5.07 - i checked)-
In my
servlet List instList=instbeerExpert.getBrands(c);
for(Object beerbrand:instList){
out.println("<br>Try "+beerbrand);
}
In the
jsp List styles=request.getAttribute("styles");
for(Object style:styles){
out.print("<br>Try: "+style);
}
The above jsp gives the following error-
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 8 in the jsp file: /result.jsp
Generated servlet error:
Type mismatch: cannot convert from Object to List
The error goes away when i typecast-
List styles=(List)request.getAttribute("styles");
Why do i have to do this typecasting?
And oh, yes, the code is from the HF Servlets and JSP book, thats why it probably looks familiar :P