org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 32 in the jsp file: /showProductCatalog.jspDVD cannot be resolved to a type29: <%while(prodListIterator.hasNext())30:{31:32:DVDmovie=(DVD)prodListIterator.next();33:StringmovieQuantity="movieQuantity";34:35:%>An error occurred at line: 32 in the jsp file: /showProductCatalog.jspDVD cannot be resolved to a type29: <%while(prodListIterator.hasNext())30:{31:32:DVDmovie=(DVD)prodListIterator.next();33:StringmovieQuantity="movieQuantity";34:35:%>Stacktrace: org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439) org.apache.jasper.compiler.Compiler.compile(Compiler.java:349) org.apache.jasper.compiler.Compiler.compile(Compiler.java:327) org.apache.jasper.compiler.Compiler.compile(Compiler.java:314) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:326) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717)note The full stack trace of the root cause is available in the Apache Tomcat/6.0.32 logs.
douglasmorais
E aqui esta o ProductDataBean:
packagecom.kayqian.dao;importjava.io.Serializable;importjava.sql.Connection;importjava.sql.PreparedStatement;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;importjava.util.ArrayList;importcom.kayqian.bean.DVD;importcom.sun.org.apache.regexp.internal.recompile;publicclassProductDataBaseBeanimplementsSerializable{privatestaticConnectionconnection;privatePreparedStatementaddRecord,getRecords;publicProductDataBaseBean(){this.connection=newConnectionFactory().getConnection();}publicArrayListgetProductList()throwsSQLException{ArrayListproductList=newArrayList();Statementstatement=connection.createStatement();ResultSetresults=statement.executeQuery("Select * from products");while(results.next()){DVDmovie=newDVD();movie.setM_cod(results.getInt(1));movie.setM_movie(results.getString(2));movie.setM_rated(results.getString(3));movie.setM_year(results.getString(4));movie.setM_price(results.getDouble(5));movie.setQuantity(results.getInt(6));productList.add(movie);}returnproductList;}}
Hebert_Coelho
Ou vc não copiou certo ou o livro ta errado. =P
Você não importou a classe DVD, olha a mensagem de erro:
An error occurred at line: 32 in the jsp file: /showProductCatalog.jsp
DVD cannot be resolved to a type
douglasmorais
Mas no livro nao tem import pra classe DVD.
douglasmorais
Deixa eu ver se entendi. Pelo fato do getProductList() retornar um list ao inves de um list de DVD eu teria que ter importado a classe DVD ?
E
evefuji
vc criou a classe DVD? Se não tem o import, provavelmente o livro diz para criar a classe DVD no mesmo package.
douglasmorais
Com relacao a criar a classe DVD no mesmo pacote nao esta explicito no livro. Vou copiar pro mesmo package pra ver no que da
douglasmorais
Puts… o erro continua…
Estou usando o eclipse e justamente a linha
DVDmovie=(DVD)prodListIterator.next();
aparece com aquele sinal vermelho de errado, grifando tanto a palavra DVD quanto (DVD).
Hebert_Coelho
douglasmorais:
Puts… o erro continua…
Estou usando o eclipse e justamente a linha
DVDmovie=(DVD)prodListIterator.next();
aparece com aquele sinal vermelho de errado, grifando tanto a palavra DVD quanto (DVD).
Novamente, faça o import da classe. O livro está errado, acontece. [=
douglasmorais
Amigo, muito obrigado por sua atencao. Fiz o import e o erro mudou.