在Tomcat中,JSP怎样调用beans ?
编译Hello.java并保存在当前目录(webapps\jszy\jsp\beans\example_h\)
调用文件example.jsp在下(webapps\jszy\jsp\)
用http://myServer:8080/jszy/jsp/example.jsp访问,出错提示:
org.apache.jasper.JasperException: Unable to compile class for JSPC:\tomcat\work\localhost_8080%2Fjszy\_0002fjsp_0002fexample_0002ejspexample_jsp_0.java:63: ???? example_h.Hello?
example_h.Hello HelloBeans = null;
^
C:\tomcat\work\localhost_8080%2Fjszy\_0002fjsp_0002fexample_0002ejspexample_jsp_0.java:66: ???? example_h.Hello?
HelloBeans= (example_h.Hello)
^
C:\tomcat\work\localhost_8080%2Fjszy\_0002fjsp_0002fexample_0002ejspexample_jsp_0.java:71: ???? example_h.Hello?
HelloBeans = (example_h.Hello) Beans.instantiate(this.getClass().getClassLoader(), "example_h.Hello");
^
3 ???
.......
=======================================================================
Hello.java原文件:
package example_h;
public class Hello {
public String name="Every one!";
public String output() {
return "Hello "+name;
}
}
-----------------------------------------------------------------------
example.jsp原文件:
<html>
<head>
</head>
<body>
<jsp:useBean id="HelloBeans" scope="session" class="example_h.Hello" />
<%=HelloBeans.output()%>
<hr>
<%
out.print("<hr size=1 color=#000000><br>");
HelloBeans.name = "world";
out.print(HelloBeans.ouput());
%>
</body>
</html>
====================================================================
问题出在哪?