您现在的位置:计算机技术学习网 > 技术中心 > WEB编程 > JSP >

jsp中实现批量删除(3)

来源:未知 责任编辑:责任编辑 发表时间:2014-05-20 18:33 点击:

throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
PrintWriter out=response.getWriter();
String[] selectdelete = request.getParameterValues("selectdelete");
String ids ="";
for(int i=0;i<selectdelete.length;i++){
ids += "'"+selectdelete[i]+"'";
if(i!=selectdelete.length-1) ids+=",";
}
String sql = "delete from COMMON where id in ("+ids+")";
Connection con = null;
Statement dodel = null;
DBcon dbcon = new DBcon();
try
{
con = dbcon.getConn();
dodel = con.createStatement();
dodel.executeUpdate(sql);

    con.close();
 }
catch(Exception e)
{
e.printStackTrace();
}
out.print("<script language='javascript'>alert('Do Success');window.location.href='delete.jsp';</script>");
out.flush();
out.close();

}


/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
}


}

发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • JSP与Servlet
  • 自己动手写MiniBBS系列(基本篇)之用户登录
  • JSP取当前日期
  • JDBC 入门(一)
  • 打开一个jsp页面默认查询所有数据,调用action
  • 使用JSP标签库验证用户的输入(2)完
  • 自定义JSP标签(tag)浅议
  • WIN98/2000下的jsp服务器
  • JSP内建对象(二)
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1