admin/member/Write.java
페이지 정보
본문
package admin.member;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import dao.MemberDAO;
import model.Member;
@WebServlet("/admin/member/write")
public class Write extends HttpServlet {
private static final long serialVersionUID = 1L;
public Write() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
RequestDispatcher dis = request.getRequestDispatcher("write.jsp");
dis.forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
String id = request.getParameter("mb_id");
Member m = new Member();
m.setId(request.getParameter("mb_id"));
m.setPass(request.getParameter("mb_pass"));
m.setName(request.getParameter("mb_name"));
m.setEmail(request.getParameter("mb_email"));
m.setAge(Integer.parseInt(request.getParameter("mb_age")));
m.setGender(request.getParameter("mb_gender"));
m.setLevel("1"); //레밸 1
m.setMemo(request.getParameter("mb_memo"));
MemberDAO dao = new MemberDAO();
int num = dao.loginSelect(id); //아이디 존재여부
if(num == 1) { //아이디 존재
//출력 구문
response.setContentType("text/html; charset=utf-8");
PrintWriter out = response.getWriter();
out.print("<script>");
out.print("alert('존재하는 아이디입니다.');");
out.print("history.back();");
out.print("</script>");
}else {
dao.insertMember(m);
response.sendRedirect("list");
}
}
}
- 이전글admin/member/list.jsp 23.03.18
- 다음글admin/member/Modify.java 23.03.18
댓글목록
등록된 댓글이 없습니다.