Estou iniciando meus trabalhos com Jsp, Servelts, Javabeans + Tomcat
Tive alguns probleminhas com o jsp e a servlet mais foi tudo ok, mas quando eu tento usar Java beans ele da um erro de compilacao nao sei o que é
Segue o erro que aparece no tomcat e o código de exemplo que estou testando esse erro.
Nao sei se precisa adicionar algo no web.xml
Obrigado pela ajuda
[list]
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
An error occurred at line: 7 in the jsp file: /index.jsp
Generated servlet error:
C:\Documents and Settings\Eduardo.netbeans\5.0\jakarta-tomcat-5.5.9_base\work\Catalina\localhost\WebApplication\org\apache\jsp\index_jsp.java:48: cannot find symbol
symbol : class TesteBean
location: class org.apache.jsp.index_jsp
TesteBean Teste = null;
^
An error occurred at line: 7 in the jsp file: /index.jsp
Generated servlet error:
C:\Documents and Settings\Eduardo.netbeans\5.0\jakarta-tomcat-5.5.9_base\work\Catalina\localhost\WebApplication\org\apache\jsp\index_jsp.java:50: cannot find symbol
symbol : class TesteBean
location: class org.apache.jsp.index_jsp
Teste = (TesteBean) _jspx_page_context.getAttribute(“Teste”, PageContext.PAGE_SCOPE);
^
An error occurred at line: 7 in the jsp file: /index.jsp
Generated servlet error:
C:\Documents and Settings\Eduardo.netbeans\5.0\jakarta-tomcat-5.5.9_base\work\Catalina\localhost\WebApplication\org\apache\jsp\index_jsp.java:52: cannot find symbol
symbol : class TesteBean
location: class org.apache.jsp.index_jsp
Teste = new TesteBean();
^
3 errors
[/list]
index.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<jsp:useBean id="Teste" class="TesteBean" />
<%=Teste.calcProcoLote(10)%>
</body>
</html>
public class TesteBean{
private int m_PrecoUnid = 10;
public int calcProcoLote(int p_quantProds){
return p_quantProds * m_PrecoUnid;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>
SE</display-name>
<servlet>
<description>
</description>
<display-name>
ChatCliente</display-name>
<servlet-name>ChatCliente</servlet-name>
<servlet-class>
ChatCliente</servlet-class>
</servlet>
<servlet>
<description>
</description>
<display-name>
TesteBean</display-name>
<servlet-name>TesteBean</servlet-name>
<servlet-class>
TesteBean</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ChatCliente</servlet-name>
<url-pattern>/ChatCliente</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>TesteBean</servlet-name>
<url-pattern>/TesteBean</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>