DeleteDraftServlet.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 DeleteDraftServlet 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="update mail set box_name=? where id=?";
- String str = request.getParameter("str");
- String []ss=str.split(":");
- Connection conn = DBManager.getConnection();
- for(String s:ss){
- int id = Integer.parseInt(s);
- try {
- PreparedStatement ps = conn.prepareStatement(sql);
- ps.setString(1, "laji");
- ps.setInt(2, id);
- ps.execute();
-
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }response.sendRedirect("DraftboxServlet");
- }
- }