一个简单jsp程序
源代码在线查看: delete.java
/*
* delete.java
*
* Created on 2007年11月21日, 下午1:53
*/
package servlet;
import dianping.DB;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
*冷漠大神 q 361619004
* @author Angel
* @version
*/
public class delete extends HttpServlet {
/** Processes requests for both HTTP GET and POST methods.
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String id=request.getParameter("id");
DB db=new DB();
db.MSupdate("delete from web where id="+id);
response.sendRedirect("index.jsp");
/* TODO output your page here
out.println("");
out.println("");
out.println("Servlet delete");
out.println("");
out.println("");
out.println("Servlet delete at " + request.getContextPath () + "");
out.println("");
out.println("");
*/
out.close();
}
//
/** Handles the HTTP GET method.
* @param request servlet request
* @param response servlet response
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/** Handles the HTTP POST method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/** Returns a short description of the servlet.
*/
public String getServletInfo() {
return "Short description";
}
//
}