关于JSP利用线程的测试出错啊!
_________________
test.jsp:
-----------------
<%@ page contentType="text/html; charset=GBK" %>
<%@page import="java.util.*"%>
<jsp:useBean id="tt" scope="page" class="TimePrinter" />
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<%
Thread t1 = new Thread(new TimePrinter(1000, "Fast Guy"));
t1.start();
Thread t2 = new Thread(new TimePrinter(3000, "Slow Guy"));
t2.start();
%></body>
</html>
____________________________
bean文件TimePrinter.java
----------------------------
import java.util.*;
public class TimePrinter implements Runnable {
int pauseTime;
String name;
public TimePrinter(int x, String n) {
pauseTime = x;
name = n;
}
public void run() {
while(true) {
try {
System.out.println(name + ":" + new
Date(System.currentTimeMillis()));
Thread.sleep(pauseTime);
} catch(Exception e) {
System.out.println(e);
}
}
}
}
______________________________
错误:(resin服务器)
------------------------------
500 Servlet Exception
java.lang.InstantiationException: `TimePrinter' has no public zero-arg
constructor
at _test__jsp._jspService(/oa/test.jsp:7)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.subservice(Page.java:497)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:246)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:163)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:536)
--------------------------------------------------------------------------------
Resin 2.1.8 (built Thu Mar 6 11:50:23 PST 2003)