帮忙看下这个程序!!!怎么总报错。。我是照着书写的啊。。菜鸟急。。

take5 2003-01-24 11:21:34
<html>
<head>
<title>jishuqi</title>
</head>
<body>
<%@ page import="java.io.*" %>
<%
//out.println(request.getHeader("Cookie"));
String currentRecord==null;
BufferedReader file;
String nameOfTextFile="count.txt";
file=new BufferedReader(new FileReader(NameOfTextFile));
String readStr =null;
int writeStr=0;
try
{
readstr=file.readLine();

catch (IOException e)
{
System.out.println("it is worry");
}
if (readStr==null)
readStr="NO message";
else if (request.gethearder("Cookie")==null)
{
writeStr=Integer.parseInt(readStr)+1;
}
else
{
writeStr=Integer.parseInt(readStr);
}
if (request.getheader("Cookie")==null)
{
try
PrintWriter pw =( new PrintWriter(new FileoutputStream(nameOfTextFile));
pw.println(writeStr);
pw.close;
}
catch(IOException e)
{
out.println(e.getmessage());
}
}
%>
<p align="center">you are num<b>
<font color="red"><%=writeStr%></font></b>people.</p>
</body>
</html>


下面是resin的报错信息
Note: sun.tools.javac.Main has been deprecated.
/jishu.jsp:19: 'catch' without 'try'.
catch (IOException e)
^
/jishu.jsp:35: '{' expected.
try
^
/jishu.jsp:36: ')' expected.
PrintWriter pw =( new PrintWriter(new FileoutputStream(nameOfTextFile));
^
/jishu.jsp:40: 'catch' without 'try'.
catch(IOException e)
^
/jishu.jsp:46: 'try' without 'catch' or 'finally'.
pageContext.write(_jsp_string2, 0, _jsp_string2.length);
^
5 errors, 1 warning

...全文
29 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
xycleo 2003-01-24
  • 打赏
  • 举报
回复
out.println(e.getmessage());要注意大小写e.getMessage()
xycleo 2003-01-24
  • 打赏
  • 举报
回复
你要把这些定义的currentRecord,rs....放到try的外面!!

在里面负值
take5 2003-01-24
  • 打赏
  • 举报
回复

按各位老大的方法改正后测试有出现以下错误!!!!!!!!!!!
Note: sun.tools.javac.Main has been deprecated.
/jishu.jsp:9: Invalid declaration.
String currentRecord==null;
^
/jishu.jsp:12: Undefined variable: NameOfTextFile
file=new BufferedReader(new FileReader(NameOfTextFile));
^
/jishu.jsp:17: Undefined variable: readstr
readstr=file.readLine();
^
/jishu.jsp:25: Method gethearder(java.lang.String) not found in interface
javax.servlet.http.HttpServletRequest.
else if (request.gethearder("Cookie")==null)
^
/jishu.jsp:33: Method getheader(java.lang.String) not found in interface
javax.servlet.http.HttpServletRequest.
if (request.getheader("Cookie")==null)
^
/jishu.jsp:36: Class FileoutputStream not found.
PrintWriter pw =( new PrintWriter(new FileoutputStream(nameOfTextFile)));
^
/jishu.jsp:39: Exception java.io.IOException is never thrown in the body
of the corresponding try statement.
}catch(IOException e)
^
/jishu.jsp:41: Method getmessage() not found in class java.io.IOException.
out.println(e.getmessage());
^
8 errors, 1 warning

lkenshin 2003-01-24
  • 打赏
  • 举报
回复
方法后面是需要()的
lkenshin 2003-01-24
  • 打赏
  • 举报
回复
pw.close();
take5 2003-01-24
  • 打赏
  • 举报
回复
Note: sun.tools.javac.Main has been deprecated.
/jishu.jsp:38: Invalid expression statement.
pw.close;
^
1 error, 1 warning
还有一个错误啊???怎么改也改不对啊。。
zxhong 2003-01-24
  • 打赏
  • 举报
回复
catch (IOException e)
->
}catch (IOException e)

try
->
try{

PrintWriter pw =( new PrintWriter(new FileoutputStream(nameOfTextFile));
->
PrintWriter pw =( new PrintWriter(new FileoutputStream(nameOfTextFile)));//后面少了个")"

that's all
hfprogramer 2003-01-24
  • 打赏
  • 举报
回复
呵呵,仔细看报错哦,呵呵,少了括弧“)”,少了“{”, :)
skyMountain 2003-01-24
  • 打赏
  • 举报
回复
根据提示可以看出:
在第十八行少了个“}”符号。
第35行try之后又少了个“{”。
另外在第46行还有什么错误就不知道了!
weimenren 2003-01-24
  • 打赏
  • 举报
回复
你自己看错误吧

你的try和carch没有匹配,还有有些地方try遗漏了{
czy412 2003-01-24
  • 打赏
  • 举报
回复
你的这个catch与哪个try对应呀1
try
{
readstr=file.readLine();

/********* catch (IOException e)
{
System.out.println("it is worry");
}
take5 2003-01-24
  • 打赏
  • 举报
回复
你要把这些定义的currentRecord,rs....放到try的外面!!

在里面负值?????????????????????
我没放在里面负值啊。。

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧