Erro no TomCate

8 respostas
Z

Boa tarde,

estou com o seguinte problema quando tento executar uma página:

HTTP Status 500 -


type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

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

Generated servlet error:
C:\Documents and Settings\Administrador.netbeans\4.1\jakarta-tomcat-5.5.7_base\work\Catalina\localhost\WebApplication2\org\apache\jsp\JSPConsultar_jsp.java:6: ‘.’ expected
import Pesquisa;
^
1 error

org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.AntCompiler.generateClass(AntCompiler.java:246)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.7 logs.


Apache Tomcat/5.5.7

alguém poderia me ajudar?

sem mais e agradecendo

8 Respostas

T

O erro está mostrado aqui, mas para decifrá-lo vamos perguntar só uma coisa.

Como você importou a classe Pesquisa? Com <%page import=“Pesquisa”%>?

Se for isso, não vai funcionar, porque a cláusula import do Java requer pelo menos um nome de pacote. Você pode fazer uma de duas coisas:

  • Ou pôr a classe Pesquisa em um pacote (package) (o recomendado)
  • Ou simplesmente omitir a cláusula “import” - pode ser que não funcione.
ldanielts

Oi,

Verifique se você está importando corretamente a classe Pesquisa (ou o que você está querendo realmente importar) na página consultar.jsp (ou JSPConsultar.jsp).

Um abraço.

Z

esse é o meu código da página

<%@page contentType=“text/html”%>
<%@page pageEncoding=“UTF-8”%>
<%–
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library… action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
–%>
<%–
<%@taglib uri=“http://java.sun.com/jsp/jstl/core” prefix=“c”%>
–%>

JSP Page
<h1>JSP Page</h1>
<%@ page import = Pesquisa %>

<jsp:useBean id=p1 scope=page class=Pesquisa />

<jsp:setProperty name=p1 property="*" />

<% p1.fazAcao(); %>

Resultado de Pesquisa

Celular:

<%--
This example uses JSTL, uncomment the taglib directive above.
To test, display the page like this: index.jsp?sayHello=true&name=Murphy
--%>
<%--
<c:if test="${param.sayHello}">
    <!-- Let's welcome the user ${param.name} -->
    Hello ${param.name}!
</c:if>
--%>

</body>

Pesquisa.java
/*

  • Pesquisa.java
  • Created on 27 de Julho de 2006, 12:49
  • To change this template, choose Tools | Options and locate the template under
  • the Source Creation and Management node. Right-click the template and choose
  • Open. You can then make changes to the template in the Source Editor.
    */

package javaapplication11;
import java.sql.*;

/**
*

  • @author Administrador
    */
    public class Pesquisa {
    // …
    //private String email;
    //private int intmod1;
    //private int dispmod1;
    private int acao;
    private String nome,fone,celular,email;
    private int intmod1,intmod2,intmod3,intmod4;
    private int dispmod1,dispmod2,dispmod3,dispmod4;
    //private int acao;
static Connection con = null;

public Pesquisa() {

if (con == null) {

try {

Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);

con = DriverManager.getConnection(“jdbc:odbc:OPINIAO,

tutdb, tutdb);

} catch (Exception e) {

System.err.println (“Erro no comando de Conexao”);

}

}

}
public boolean fazAcao() {

if (acao == 1) {

try {

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery ("SELECT * FROM "+

“TREINAMENTO”);

if (rs.next()) {

nome = rs.getString(1);

fone = rs.getString(2);

//celular = rs.getString(“celular”);

email = rs.getString(4);

intmod1 = rs.getInt(“intmod1”);

intmod2 = rs.getInt(6);

intmod3 = rs.getInt(7);

intmod4 = rs.getInt(8);

dispmod1 = rs.getInt(9);

dispmod2 = rs.getInt(10);

dispmod3 = rs.getInt(11);

dispmod4 = rs.getInt(12);

}

else {

acao = 3;

fazAcao();

return false;

}

stmt.close();

}

catch (Exception e) {

System.err.println (“Erro no comando SQL de Consulta”);

return false;

}

}

// …

return true;

}
// …

public String getEmail() {

return email;

}
public void setEmail(String email) {

this.email = email;

}
public int getIntmod1() {

return intmod1;

}
public void setIntmod1(int intmod1) {

this.intmod1 = intmod1;

}
public int getAcao() {

return acao;

}
public void setAcao(int acao) {

this.acao = acao;

}

}

você poderia dar uma olhada pra mim

Interesse Disponibilidade
Mod1
T

Troque por

<%@ page import = "javaapplication11.Pesquisa" %>

ou se você for preguiçoso,

<%@ page import = "javaapplication11.*" %>
Z

ai fiz isso mais nem funcionou continua dando o seguinte erro:

HTTP Status 500 -


type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

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

Generated servlet error:
C:\Documents and Settings\Administrador.netbeans\4.1\jakarta-tomcat-5.5.7_base\work\Catalina\localhost\WebApplication2\org\apache\jsp\JSPConsultar_jsp.java:6: package WebApplication2 does not exist
import WebApplication2.Pesquisa;
^

An error occurred at line: 24 in the jsp file: /JSPConsultar.jsp
Generated servlet error:
C:\Documents and Settings\Administrador.netbeans\4.1\jakarta-tomcat-5.5.7_base\work\Catalina\localhost\WebApplication2\org\apache\jsp\JSPConsultar_jsp.java:60: cannot access org.apache.jsp.Pesquisa

An error occurred at line: 24 in the jsp file: /JSPConsultar.jsp
Generated servlet error:
bad class file: C:\Documents and Settings\Administrador.netbeans\4.1\jakarta-tomcat-5.5.7_base\work\Catalina\localhost\WebApplication2\org\apache\jsp\Pesquisa.java
file does not contain class org.apache.jsp.Pesquisa
Please remove or make sure it appears in the correct subdirectory of the classpath.
Pesquisa p1 = null;
^
2 errors

org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.AntCompiler.generateClass(AntCompiler.java:246)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.7 logs.


ldanielts

Cara,

O pacote que você enviou primeiro foi javaapplication11 e não WebApplication2.

Verifique isso, compile novamente o Java (se necessário) e tente outra vez.

Ah, e só uma sugestãozinha boba mas que acredito que vai te ajudar pela vida afora. Você criou o tópico como Erro no TomCate. Eu nem tinha visto, mas vi agora. Isso chega a doer nos olhos. Mesmo sendo iniciante, você deve dar o nome correto às tecnologias que utilizar.

Um abraço.

T

Parece casal de artistas americanos em revistas de fofocas (quem assiste ao E! Entertainment Television sabe de que estou falando).
TomKat = Tom Cruise + Katie Holmes
TomCate = Tom Cruise + Cate Blanchett
Brangelina = Brad Pitt + Angelina Jolie

Z

foi mla foi apenas um “e” a + devido a pressa em escrever… mais mil desculpas.
e continua dando erro

Criado 27 de julho de 2006
Ultima resposta 27 de jul. de 2006
Respostas 8
Participantes 3