DraftboxDeleteServlet.java
上传用户:liangcc
上传日期:2019-05-24
资源大小:4412k
文件大小:1k
- package com.softeem.webmail.draftbox;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.softeem.webmail.dao.DBManager;
- public class DraftboxDeleteServlet extends HttpServlet {
-
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- doPost(request, response);
- }
- public void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- response.setContentType("text/html;charset=UTF-8");
- request.setCharacterEncoding("UTF-8");
- String sql = "delete from mail where id=?";
- String str = request.getParameter("str");
- String []ss = str.split(":");
- Connection conn = DBManager.getConnection();
- try {
- PreparedStatement ps = conn.prepareStatement(sql);
- for(String s:ss){
- int id = Integer.parseInt(s);
- ps.setInt(1, id);
- ps.execute();
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- response.sendRedirect("DraftboxServlet");
- }
- }