什么时候会使一个javaBean的实例=null??急救啊!
//以下是.jsp里的
<%@page contentType="text/html;charset=GBK"%>
<jsp:useBean id="RW" class="test" />
<%=RW.read("o:\\test.txt")
%>
<%=RW.write("o:\\test1.txt")
%>
***************************************************************************************
//这个是我设计的javaBean
import java.io.*;
import java.lang.*;
public class Test{
private String readfile;
private String writefile;
public void read(String filename) throws IOException
{
File objFile;
FileReader objFileReader;
char []chrBuffer=new char[20];
int intLength ;
try{
objFile = new File(filename);
if ( objFile.exists() ){
objFileReader = new FileReader(objFile);
while((intLength =objFileReader.read(chrBuffer)) != -1){
System.out.println(chrBuffer);
}
objFileReader.close();
}
}catch(IOException e){
}
}
public void write(String filename)
{
try
{
PrintWriter pw = new PrintWriter(new FileOutputStream(filename));
String str = new String ("lanziman!");
pw.println(str);
pw.close();
}catch(FileNotFoundException e)
{
}
}
}
*********************************************************************************
//报的错误以下:
Generated servlet error:
[javac] Compiling 1 source file
D:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myjsp\org\apache\jsp\_1_jsp.java:44: cannot resolve symbol
symbol : class test
location: class org.apache.jsp._1_jsp
test RW = null; ^
An error occurred at line: 2 in the jsp file: /1.jsp
Generated servlet error:
D:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myjsp\org\apache\jsp\_1_jsp.java:46: cannot resolve symbol
symbol : class test
location: class org.apache.jsp._1_jsp
RW = (test) _jspx_page_context.getAttribute("RW", PageContext.REQUEST_SCOPE);^
An error occurred at line: 2 in the jsp file: /1.jsp
Generated servlet error:
D:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\myjsp\org\apache\jsp\_1_jsp.java:48: cannot resolve symbol
symbol : class test
location: class org.apache.jsp._1_jsp
RW = new test();
^
3 errors
*************************************************************************************
一个javaBean不是在用<jsp:useBean ……>
的时候就实例化了吗?为什么还有“test RW = null”??