carMAN
14-09-2004, 22:35
sono alle prime armi con i javabean, ma subito sono insorti i primi problemi. Iniziamo dal principio.
Ho compilato il seguente javabean:
import java.io.Serializable;
public class Counter implements Serializable {
int count=0;
public Counter() {}
public int getCount(){count++; return count;}
public void setCount(int count){this.count=count;}
}
nella cartella ROOT di tomcat ho creato la cartella testjsp ed in essa le cartelle innestate WEB-INF e classes. In classes ho inserito il file compilato Counter.class
Ricapitolando:
ROOT\testjsp\WEB-INF\classes\Counter.class
Successivamente ho creato il file jsp:
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="counter" scope="page" class="Counter" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Esempio di bean con ambito page</title>
</head>
<body>
<h3>Esempio di bean con ambito page</h3>
<center><b>Il valore count corrente per il bean counter è : </b>
<%=counter.getCount()%></center>
</body>
</html>
Ho inserito tale file in ROOT\testjsp
Ho avviato tomcat e ho ottenuto il seguente errore:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 2 in the jsp file: /testJSP/page_counter.jsp
Generated servlet error:
[javac] Compiling 1 source file
C:\Tomcat4\work\Standalone\localhost\_\testJSP\page_counter_jsp.java:44: cannot resolve symbol
symbol : class Counter
location: class org.apache.jsp.page_counter_jsp
Counter counter = null;
^
....
Chi mi aiuta, per favore...
Ho compilato il seguente javabean:
import java.io.Serializable;
public class Counter implements Serializable {
int count=0;
public Counter() {}
public int getCount(){count++; return count;}
public void setCount(int count){this.count=count;}
}
nella cartella ROOT di tomcat ho creato la cartella testjsp ed in essa le cartelle innestate WEB-INF e classes. In classes ho inserito il file compilato Counter.class
Ricapitolando:
ROOT\testjsp\WEB-INF\classes\Counter.class
Successivamente ho creato il file jsp:
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="counter" scope="page" class="Counter" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Esempio di bean con ambito page</title>
</head>
<body>
<h3>Esempio di bean con ambito page</h3>
<center><b>Il valore count corrente per il bean counter è : </b>
<%=counter.getCount()%></center>
</body>
</html>
Ho inserito tale file in ROOT\testjsp
Ho avviato tomcat e ho ottenuto il seguente errore:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 2 in the jsp file: /testJSP/page_counter.jsp
Generated servlet error:
[javac] Compiling 1 source file
C:\Tomcat4\work\Standalone\localhost\_\testJSP\page_counter_jsp.java:44: cannot resolve symbol
symbol : class Counter
location: class org.apache.jsp.page_counter_jsp
Counter counter = null;
^
....
Chi mi aiuta, per favore...