<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<html>
<body>
<%!
Hashtable hashtable=new Hashtable();
synchronized void putGoodsToHashtable(String key,String list)
{
hashtable.put(key,list);
}
%>
<%
String name=request.getParameter("N");
String mount=request.getParameter("M");
if(name==null||mount==null)
{
name="";
mount="";
}
else
{
byte c[]=name.getBytes("ISO-8859-1");
name=new String(c);
byte d[]=mount.getBytes("ISO-8859-1");
mount=new String(d);
}
%>
<%
File f=new File("F:/myjsp/bookexam","goods_name.txt");
if(f.exits())
{
try
{
FileInputStream in=new FileInputStream(f);
ObjectInputStream object_in=new ObjectInputStream(in);
hashtable=(Hashtable)object_in.readObject();
in.close();
if(hashtable.containsKey(name)
{
session.setAttribute("name",name);
response.sendRedirect("del.jsp");//重定向到修改页面
}
else
{
String s="#"+name+"#"+mount+"#";
putGoodsToHashtable(name,s);
try
{
FileOutputStream o=new FileOutputStream(f);
ObjectOutputStream object_out=new ObjectOutputStream(o);
object_out.writeObject(hashtable);
object_out.close();
o.close();
}
catch(Exception eee){}
        out.print("<br>"+"您已经将货物存入文件");
        out.print("<br>"+"货物的货号:"+name);
  }
}
catch(IOException e){}
}
else
{
String s="#"+name+"#"+mount+"#";
putGoodsToHashtable(name,s);
try
{
FileOutputStream o=new FileOutputStream(f);
ObjectOutputStream object_out=new ObjectOutputStream(o);
object_out.writeObject(hashtable);
object_out.close();
o.close();
out.print("<br>"+"您是第一个录入货物的人");
out.print("<br>"+"货物的货号:"+name);
}
catch(Exception eee){}
}
%>
<table border="2">
<tr>
<td>
<form action="Example4_11.jsp" method="post">
<input type="submit" value="录入界面">
</form>
</td>
<td>
<form action="showgoods.jsp" method="post">
<input type="submit" value="查看界面">
</form>
</td>
</tr>
</table>
</body>
</html>

解决方案 »

  1.   

    An error occurred at line: 29 in the jsp file: /input.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\bookexam\org\apache\jsp\input_jsp.java:90: ')' expected
    {
                                            ^
    An error occurred at line: 29 in the jsp file: /input.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\bookexam\org\apache\jsp\input_jsp.java:110: illegal start of expression
    }
                                    ^
    2 errors
      

  2.   

    错误是少了一个“)”
    【if(hashtable.containsKey(name) 】这里少了一个括号。