📄 c0af9f72a0bc001d1a0bdb0e07cbdb75
字号:
package org.MyServlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.dbUtil.DBUtil;
public class EditServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public EditServlet() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
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
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
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
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String id = request.getParameter("id");
String kn = request.getParameter("kn");
String EmployId = request.getParameter("EmployId");
String EmployName = request.getParameter("EmployName");
String EmployStreet = request.getParameter("EmployStreet");
String EmployPro = request.getParameter("EmployPro");
String EmployCity = request.getParameter("EmployCity");
String EmployZip = request.getParameter("EmployZip");
String EmployTel = request.getParameter("EmployTel");
String EmployFun = request.getParameter("EmployFun");
String EmploySex = request.getParameter("EmploySex");
String EmployBir = request.getParameter("EmployBir");
String EmployWel = request.getParameter("EmployWel");
String EmployEarn = request.getParameter("EmployEarn");
if (id.equals("insert") == false) {
String updateSQL = "update wid set peopname='" + EmployName
+ "',p_street='" + EmployStreet + "',p_City='" + EmployCity
+ "',p_prov='" + EmployPro + "',p_zip='" + EmployZip
+ "',peoptel='" + EmployTel + "',peopbirth='" + EmployBir
+ "',peopsex='" + EmploySex + "',welfareno='" + EmployWel
+ "',peopearn='" + EmployEarn + "',peopfunc='" + EmployFun
+ "' where did='" + kn + "'";
DBUtil.update(updateSQL);
request.getRequestDispatcher("/myapps/edit/list.jsp?n="+kn)
.forward(request, response);
} else {
// ID = DBUtil.returnID().toString();
String insertSQL = "insert into wid(peopname,p_street,p_City,p_prov,p_zip,peoptel,peopbirth,peopsex,welfareno,peopearn,peopfunc,did) "
+ "values("
+ "'"
+ EmployName
+ "','"
+ EmployStreet
+ "','"
+ EmployCity
+ "','"
+ EmployPro
+ "','"
+ EmployZip
+ "','"
+ EmployTel
+ "','"
+ EmployBir
+ "','"
+ EmploySex
+ "','"
+ EmployWel
+ "','"
+ EmployEarn
+ "','"
+ EmployFun
+ "','"
+ EmployId
+"')";
DBUtil.exe(insertSQL);
request.getRequestDispatcher("/myapps/edit/list.jsp?n="+EmployId)
.forward(request, response);
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException
* if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -