Fala Moçada…
É o seguinte... tô começando agora a usar JSP+Bean... mas tô tomando um coro daquele malandros.... queria saber se alguém pode me ajudar... tô precisando muito aprender isto rápidinho...
Estou fazendo um teste bem bobo... mas nem mesmo ele consegue executar... bem... aí vão os códigos!
index.jsp
<jsp:useBean id='hello' class='HelloBean' />
<html>
<head>
<title> Hello World em Bean </title>
</head>
<body>
<h1>Saudação tosca em Bean</h1>
<p>
Esta é a minha saudação :
<jsp:getProperty name='hello' property='greeting' />
</p>
</body>
</html>
este é o código da classe HelloBean.class
public class HelloBean
{
private String greeting;
public HelloBean()
{
this.greeting = "Hello World";
}
public String getGreeting()
{
return this.greeting;
}
}
Estou usando como servidor web o Tomcat 5.0.28, e os aqruivos estão nas seguintes pastas...
-
‘C:\Arquivos de programas\Apache Software Foundation\Tomcat 5.0\webapps\teste\index.jsp’
-
‘C:\Arquivos de programas\Apache Software Foundation\Tomcat 5.0\webapps\teste\WEB-INF\classes\HelloBean.class’
Quando eu executo o jsp o Tomcat me mostra os seguintes erros…
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: 1 in the jsp file: /index.jsp
Generated servlet error:
C:\Arquivos de programas\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\teste\org\apache\jsp\index_jsp.java:42: cannot resolve symbol
symbol : class HelloBean
location: class org.apache.jsp.index_jsp
HelloBean hello = null;
^
An error occurred at line: 1 in the jsp file: /index.jsp
Generated servlet error:
C:\Arquivos de programas\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\teste\org\apache\jsp\index_jsp.java:44: cannot resolve symbol
symbol : class HelloBean
location: class org.apache.jsp.index_jsp
hello = (HelloBean) _jspx_page_context.getAttribute("hello", PageContext.PAGE_SCOPE);
^
An error occurred at line: 1 in the jsp file: /index.jsp
Generated servlet error:
C:\Arquivos de programas\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\teste\org\apache\jsp\index_jsp.java:46: cannot resolve symbol
symbol : class HelloBean
location: class org.apache.jsp.index_jsp
hello = new HelloBean();
^
An error occurred at line: 14 in the jsp file: /index.jsp
Generated servlet error:
C:\Arquivos de programas\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\teste\org\apache\jsp\index_jsp.java:64: cannot resolve symbol
symbol : class HelloBean
location: class org.apache.jsp.index_jsp
out.write(org.apache.jasper.runtime.JspRuntimeLibrary.toString((((HelloBean)_jspx_page_context.findAttribute("hello")).getGreeting())));
^
4 errors
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
Pelo amor de Deus… alguém me ajuda…
Obrigado…
Java-Eater…
