String resultDir="c:"; FileInputStream tfile=new FileInputStream(resultDir+System.getProperty("file.separator")+"EE.txt"); String str=""; int c; while ((c=tfile.read())!=-1){ str=str+(char)c; } int first=str.indexOf(":"); int last=str.indexOf(":"); int lenth=str.length(); String firststr=str.substring(0,first); String middlestr=str.substring(first+1,last); String laststr=str.substring(last+1,lenth); tfile.close(); Long a1=new Long(firststr); Long a2=new Long(middlestr); Long a3=new Long(laststr); long b1=a1.longValue(); long b2=a2.longValue(); long b3=a3.longValue(); long total=b1+b2+b3; float h1=100*((float)b1/(float)total); float h2=100*((float)b2/(float)total); float h3=100*((float)b3/(float)total); out.println("1:"+b1+"<br>"); out.println("2:"+b2+"<br>"); out.println("3:"+b3+"<br>");这段代码有错吗,已经把包包进来了 java.util.*,java.lang.*,java.io.*
FileInputStream tfile=new FileInputStream(resultDir+System.getProperty("file.separator")+"EE.txt");
String str="";
int c;
while ((c=tfile.read())!=-1){
str=str+(char)c;
}
int first=str.indexOf(":");
int last=str.indexOf(":");
int lenth=str.length();
String firststr=str.substring(0,first);
String middlestr=str.substring(first+1,last);
String laststr=str.substring(last+1,lenth);
tfile.close();
Long a1=new Long(firststr);
Long a2=new Long(middlestr);
Long a3=new Long(laststr);
long b1=a1.longValue();
long b2=a2.longValue();
long b3=a3.longValue();
long total=b1+b2+b3;
float h1=100*((float)b1/(float)total);
float h2=100*((float)b2/(float)total);
float h3=100*((float)b3/(float)total);
out.println("1:"+b1+"<br>");
out.println("2:"+b2+"<br>");
out.println("3:"+b3+"<br>");这段代码有错吗,已经把包包进来了
java.util.*,java.lang.*,java.io.*
有时出错信息已经很清楚告诉你是怎么回事了?
是不是有什么方法会抛出异常的 调用这些方法必须用try catchjsp一般会提示那一行出错了
你可以找到它转换后的servlet看看那一行怎么错了 对照你的jsp 一般都可以解决
有时出错信息已经很清楚告诉你是怎么回事了?
是不是有什么方法会抛出异常的 调用这些方法必须用try catchjsp一般会提示那一行出错了
你可以找到它转换后的servlet看看那一行怎么错了 对照你的jsp 一般都可以解决
FileInputStream tfile=new FileInputStream(resultDir+System.getProperty("file.separator")+"EE.txt");
这句最可能了,你输出:resultDir+System.getProperty("file.separator")+"EE.txt"的结果看看是什么.
int c;
try{
FileInputStream tfile=new FileInputStream(resultDir+System.getProperty("file.separator")+"EE.txt");
while ((c=tfile.read())!=-1){
str=str+(char)c;
}
}catch(Exception e){
e.printStackTrace(System.out);//去后台看看什么错了
}
因为在由JSP-->转化为Servlet时,JSP容器会给整个JSP代码加上一个try...catch。然后处理JSP代码中异常的手段是,看你是否在JSP申明了errorPage(<%@page errorPage="error_url" %>),如果声明了就会将异常抛出传递到errorPage,否则就直接将该异常显示出来。当然,前提是你的JSP没有语法问题,否则出现的错误那不叫运行产生异常,那叫做编译不通过。
不过,你也根据需要而不采用这种默认的异常处理方式,即在可能产生异常的地方自己来捕获并处理。
我建议最好使用try..catch..这样的话可以降低在开发
时的难度
建议加上try..catch..这样可以降低开发的难度。
尤其当出现500错误的时候,不加try..catch..简直就没有办法
调试