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

📄 itemdelete.jsp

📁 《jsp案例开发》这本书的源代码。包括源代码和相关的具体配置操作步骤。非常不错
💻 JSP
字号:
<%@ page    language="java"    contentType="text/html; charset=GBK"    import="imis.*,javax.naming.*,javax.rmi.PortableRemoteObject,java.util.*,java.io.*,java.sql.*"%><%  request.setCharacterEncoding("GBK");  session=request.getSession();  userStruct user=(userStruct)session.getAttribute("user");  if(user==null){  response.sendRedirect("../../login.html");  }  else if(user.userAccess.intValue()!=9&&user.userAccess.intValue()!=10)    response.sendRedirect("../../error/access.html");else{%><%Integer itemid = new Integer(request.getParameter("itemid"));boolean ok = true;Context ctx = new InitialContext();//look up jndi nameObject ref = ctx.lookup("Item1Controller");//cast to Home interfaceItem1ControllerHome itemControllerHome = (Item1ControllerHome) PortableRemoteObject.narrow(ref, Item1ControllerHome.class);Item1Controller itemController = itemControllerHome.create();Collection bidc = new ArrayList();Collection examc = new ArrayList();Collection tc = new ArrayList();tc = itemController.getBidbookByItemid(itemid);Iterator ti = tc.iterator();while(ti.hasNext()){BidbookStruct bbs = (BidbookStruct)ti.next();bidc.add(bbs.bidbookid);}Collection etc = new ArrayList();etc = itemController.getExamByItemid(itemid);Iterator eti = etc.iterator();while(eti.hasNext()){ExamStruct es = (ExamStruct)eti.next();examc.add(es.examid);}SqlStruct ss = new SqlStruct();Class.forName(ss.forname).newInstance();Connection conn= DriverManager.getConnection(ss.url,ss.username,ss.password);try{conn.setAutoCommit(false);System.out.println("1234");String sql1 = "DELETE FROM ITEMTABLE WHERE ITEMID=?";String sql2 = "DELETE FROM BIDTEAM WHERE ITEMID=?";String sql3 = "DELETE FROM BIDTEAM_X_EMPL WHERE ITEMID=?";String sql4 = "DELETE FROM BIDBOOK WHERE ITEMID=?";String sql5 = "DELETE FROM EXAM WHERE ITEMID=?";PreparedStatement ps1 = conn.prepareStatement(sql1);PreparedStatement ps2 = conn.prepareStatement(sql2);PreparedStatement ps3 = conn.prepareStatement(sql3);PreparedStatement ps4 = conn.prepareStatement(sql4);PreparedStatement ps5 = conn.prepareStatement(sql5);ps1.setInt(1,itemid.intValue());ps2.setInt(1,itemid.intValue());ps3.setInt(1,itemid.intValue());ps4.setInt(1,itemid.intValue());ps5.setInt(1,itemid.intValue());ps1.execute();ps2.execute();ps3.execute();ps4.execute();ps5.execute();ps1.close();ps2.close();ps3.close();ps4.close();ps5.close();conn.commit();System.out.println("12345");}catch(SQLException e){ok = false;  try   {   conn.rollback();   }   catch(Exception e1)   {   e1.printStackTrace();   }}conn.close();if(ok){       //删除和项目相关的文件/////Context ctx1 = new InitialContext();//look up jndi nameObject ref1 = ctx1.lookup("ItemreplyController");//cast to Home interfaceItemreplyControllerHome itemreplyControllerHome = (ItemreplyControllerHome) PortableRemoteObject.narrow(ref1, ItemreplyControllerHome.class);ItemreplyController itemreplyController = itemreplyControllerHome.create();Collection c = new ArrayList();c = itemreplyController.getItemreply(itemid,"ITEMTABLE");Iterator bti = bidc.iterator();while(bti.hasNext()){Integer id = (Integer)bti.next();Collection tcc = itemreplyController.getItemreply(id,"BIDBOOK");Iterator tii = tcc.iterator();while(tii.hasNext()){ItemreplyStruct irs = (ItemreplyStruct)tii.next();c.add(irs);}}Iterator exti = examc.iterator();while(exti.hasNext()){Integer id = (Integer)exti.next();Collection tcc = itemreplyController.getItemreply(id,"EXAM");Iterator tii = tcc.iterator();while(tii.hasNext()){ItemreplyStruct irs = (ItemreplyStruct)tii.next();c.add(irs);}}Iterator i = c.iterator();while(i.hasNext()){ItemreplyStruct irs = (ItemreplyStruct)i.next();itemreplyController.remove(irs.id);if(irs.filepath1!=null){  File f = new File(irs.filepath1);  f.delete();  String tempath = irs.filepath1;  int inde = tempath.lastIndexOf("\\");  String node = tempath.substring(0,inde);  File ff = new File(node);  ff.delete();}if(irs.filepath2!=null){  File f = new File(irs.filepath2);  f.delete();  String tempath = irs.filepath2;  int inde = tempath.lastIndexOf("\\");  String node = tempath.substring(0,inde);  File ff = new File(node);  ff.delete();}if(irs.filepath3!=null){  File f = new File(irs.filepath3);  f.delete();  String tempath = irs.filepath3;  int inde = tempath.lastIndexOf("\\");  String node = tempath.substring(0,inde);  File ff = new File(node);  ff.delete();}}       response.sendRedirect("item_query.jsp");       }       else       {       response.sendRedirect("../../error/deleteerror.html");       }%><%}%>

⌨️ 快捷键说明

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