public void delete(HttpServletRequest request, String tablename) {
int i = 0; try { String did = request.getParameter("did"); if (did == null) did = request.getParameter("scid"); if (did != null) { if (did.length() > 0) { Statement st = conn.createStatement(); System.out.println("delete from " + tablename + " where id=" + did); st.execute("delete from " + tablename + " where id=" + did); st.close(); } }
} catch (SQLException e) { // TODO Auto-generated catch block
/** * Destruction of the servlet. <br> */ publicvoiddestroy(){ super.destroy(); // Just puts "destroy" string in log // Put your code here }
/** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @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 */ publicvoiddoGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response); }
/** * 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 */ publicvoiddoPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
StringBuffer sb = new StringBuffer(50); response.setContentType("application/x-msdownload;charset=GB2312"); try { response.setHeader("Content-Disposition", new String(sb.toString() .getBytes(), "ISO8859-1")); } catch (UnsupportedEncodingException e1) { // TODO Auto-generated catch block