JSP代码如下:
<%@ page contentType="text/html; charset=GBK" import="DAO.*" %>
<html>
<head>
<title>
showing
</title>
</head>
<body bgcolor="#ffffff">
<h3>欢迎<%=request.getAttribute("list").toString()%>光临</h3>
<jsp:useBean id="counter" class="DAO.counter" scope="request">
</jsp:useBean>
<%
//调用counter对象的ReadFile方法来读取文件lyfcount.txt中的计数
String cont=counter.ReadFile("/count.txt");
//调用counter对象的ReadFile方法来将计数器加一后写入到文件lyfcount.txt中
counter.WriteFile("/count.txt",cont);%>
您是第<font color="red"><%=cont%></font>位访问者
</body>
</html>
JAVABEAN在DAO包下
错误如下:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: -1 in the jsp file: null
Generated servlet error:
[javac] Compiling 1 source file
[javac] E:\星座\Tomcat\work\WebModule1\showing_jsp.java:7: 软件包 DAO 不存在
[javac] import DAO.*;
[javac] ^
[javac] E:\星座\Tomcat\work\WebModule1\showing_jsp.java:53: 软件包 DAO 不存在
[javac] DAO.counter counter = null;
[javac] ^
[javac] E:\星座\Tomcat\work\WebModule1\showing_jsp.java:55: 软件包 DAO 不存在
[javac] counter = (DAO.counter) pageContext.getAttribute("counter", PageContext.REQUEST_SCOPE);
[javac] ^
[javac] E:\星座\Tomcat\work\WebModule1\showing_jsp.java:58: 软件包 DAO 不存在
[javac] counter = (DAO.counter) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "DAO.counter");
[javac] ^
[javac] 4 错误
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:248)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:315)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:328)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:427)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:142)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:627)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:382)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:306)
at servlet.MainServlet.doGet(MainServlet.java:50)
at servlet.MainServlet.doPost(MainServlet.java:56)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:595)