package servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import dao.EmplDaoImpl;
import dao.EmplDaoInter;
import model.EmplModel;
/**
* Servlet implementation class AddEmpServlet
*/
public class AddEmpServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
*/
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
String empno = request.getParameter("empno");
String ename = request.getParameter("ename");
String sex = request.getParameter("sex");
String iden = request.getParameter("iden");
String birthDate = request.getParameter("birthDate");
String nati = request.getParameter("nati");
String address = request.getParameter("address");
String marital = request.getParameter("marital");
String nation = request.getParameter("nation");
String contact = request.getParameter("contact");
String remark = request.getParameter("remark");
EmplModel emp=new EmplModel();
emp.setEmpno(empno);
emp.setEname(ename);
emp.setSex(sex);
emp.setIden(iden);
emp.setBirthDate(birthDate);
emp.setNati(nati);
emp.setAddress(address);
emp.setMarital(marital);
emp.setNation(nation);
emp.setContact(contact);
emp.setRemark(remark);
EmplDaoInter dao = new EmplDaoImpl();
try {
int flag = dao.insertEmpl(emp);
if (flag > 0) {
request.getRequestDispatcher("selectAll").forward(request, response);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}