⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 input.jsp.bak

📁 可以让初学者有一个感性的认识
💻 BAK
字号:
<HTML>
<%@page contentType="text/html;charset=GB2312"%>
<%@page import="java.io.*" %>
<%@page import="java.util.*" %>

<BODY bgcolor=cyan><Font size=3>
	
<%!	Hashtable hashtable=new Hashtable();

	synchronized void putGoodsToHashtable(String key,String list)
		{hashtable.put(key,list);}
		
	synchronized void removeGoodsToHashtable(String key)
		{hashtable.remove(key);}
%>

<%	String name=request.getParameter("N");
	if(name==null)name="have no goods number";
	byte c[]=name.getBytes("ISO-8859-1");
	name=new String(c);
	
	String mount=request.getParameter("M");
	if(mount==null)mount="have no any recoder";
	byte d[]=mount.getBytes("ISO-8859-1");
	mount=new String(d);
%>

<%	File f=new File("d:/Tomcat/webapps/root/chap4","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();
			String temp=(String)hashtable.get(name);
			if(temp==null)temp="";
			if((temp.length())!=0)
			{
			out.print("<BR>"+"该货号已存在,您已经修改了数量");
				String s="货号:"+name+" ,数量:"+mount;
				removeGoodsToHashtable(name);
				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){}
			}
			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){}
	}
%>

<FORM action="showgoods.jsp" method=post>
	<P>查看库存情况
	<BR><INPUT type="submit" value="去查看库存">
</FORM>

<A href="Example4_11.jsp"><BR>返回录入页面

</FONT>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -