📄 input.jsp
字号:
<%@ 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("C:/","goods_name.txt");
if(f.exists())
{
try{
FileInputStream in=new FileInputStream(f);
ObjectInputStream object_in=new ObjectInputStream(in);
hashtable=(Hashtable)object_in.readObject();
object_in.close();
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>
<td>
<FORM action="del.jsp" method=post >
<INPUT type=submit value="修改界面">
</FORM>
</td>
</Table>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -