Pessoal estou estudando JSP pela apostila da caelum fj21:
fiz umas classes em java e rodou legal…
então comecei a utilizar as mesmas classes para fazer algo em JSP
mas aconteceu o seguinte erro:
An error occurred at line: 8 in the jsp file: /lista-scriptlet.jsp
ContatoDAO cannot be resolved to a type
5:
6:
- <%=contato.getNome()%>,
An error occurred at line: 12 in the jsp file: /lista-scriptlet.jsp Contato cannot be resolved to a type 9: List contatos = dao.getLista(); 10: 11: for (int i = 0; i < contatos.size(); i++ ) { 12: Contato contato = (Contato)contatos.get(i); 13: 14: %> 15:
- <%=contato.getNome()%>,
Stacktrace: org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435) org.apache.jasper.compiler.Compiler.compile(Compiler.java:298) org.apache.jasper.compiler.Compiler.compile(Compiler.java:277) org.apache.jasper.compiler.Compiler.compile(Compiler.java:265) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.27 logs.
O código é:
lista-scriptlet.jsp
<%@ page import=“com.cev.dao.<em>, com.cev.</em>” %> <%<a class="mention" href="/u/page">@page</a> import=“com.cev.modelo.*”%> <%<a class="mention" href="/u/page">@page</a> import=“java.util.List”%>
-
<%
ContatoDAO dao = new ContatoDAO();
List contatos = dao.getLista();
for (int i = 0; i < contatos.size(); i++ ) { Contato contato = (Contato)contatos.get(i);
%>
- <%=contato.getNome()%>, <%=contato.getEmail()%>: <%=contato.getEndereco()%> <% } %>
7: <%
8: ContatoDAO dao = new ContatoDAO();
9: List contatos = dao.getLista();
10:
11: for (int i = 0; i < contatos.size(); i++ ) {
An error occurred at line: 8 in the jsp file: /lista-scriptlet.jsp
ContatoDAO cannot be resolved to a type
5:
6:
7: <%
8: ContatoDAO dao = new ContatoDAO();
9: List contatos = dao.getLista();
10:
11: for (int i = 0; i < contatos.size(); i++ ) {
An error occurred at line: 12 in the jsp file: /lista-scriptlet.jsp
Contato cannot be resolved to a type
9: List contatos = dao.getLista();
10:
11: for (int i = 0; i < contatos.size(); i++ ) {
12: Contato contato = (Contato)contatos.get(i);
13:
14: %>
15: