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

📄 input.jsp

📁 JSP效果信息 各位请下载查看 比较不错的
💻 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("D:/jsp2007","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>
       </tr>
       </table>
  </body>
</html>

⌨️ 快捷键说明

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