急:jsp+javabean有错误,不知道错误在哪里?
源码如下:
Send.java
/*
*发送信息
*
*/
package com.hasons.bean;
import java.io.*;
import java.net.*;
public class Send
{
//属性
String host;
int port;
DataInputStream inStream;
DataOutputStream outStream;
public Send()
{
host="192.168.1.180";
port=8765;
try{
Socket client=new Socket(host,port);
inStream=new DataInputStream(client.getInputStream());
outStream=new DataOutputStream(client.getOutputStream());
client.setSoTimeout(3000);
}
catch(Exception e)
{}
}
public String SendMess()
{
String str="Hello";
try{
for(int index=1;index<10;index++)
{
outStream.writeUTF(str);
}
return("success");
}
catch(Exception e)
{
return("Fail");
}
}
}
该文件在D:\hasons\lib\com\hasons\bean\Send.class
Classpath中设定了:D:\hasons\lib。
在Dos下,输入java com.hasons.Send可以找到该类。
test2.jsp
<%@ page language="java" %>
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="com.hasons.bean.*" %>
<jsp:useBean id="test1" class="com.hasons.bean.Send"/>
<html>
<head>
<title>测试</title>
</head>
<body>
<%=test1.SendMess()%>
Hello
<body>
在IE中执行test2.jsp时,出现下面的错误:
HTTP Status 500 -
--------------------------------------------------------------------------------
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: null
Generated servlet error:
[javac] Since fork is true, ignoring compiler setting.
[javac] Compiling 1 source file
[javac] Since fork is true, ignoring compiler setting.
[javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\hasons\test2_jsp.java:7: package com.hasons.bean does not exist
[javac] import com.hasons.bean.*;
[javac] ^
[javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\hasons\test2_jsp.java:46: package com.hasons.bean does not exist
[javac] com.hasons.bean.Send test1 = null;
[javac] ^
[javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\hasons\test2_jsp.java:48: package com.hasons.bean does not exist
[javac] test1 = (com.hasons.bean.Send) pageContext.getAttribute("test1", PageContext.PAGE_SCOPE);
[javac] ^
[javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\hasons\test2_jsp.java:51: package com.hasons.bean does not exist
[javac] test1 = (com.hasons.bean.Send) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "com.hasons.bean.Send");
[javac] ^
[javac] 4 errors
...
想不明白是为什么。论坛中搜索也没找到解决办法,大家多帮忙啊!
先谢!