admin/member/Write.java > MODEL2

본문 바로가기

사이트 내 전체검색

뒤로가기 MODEL2

admin/member/Write.java

페이지 정보

작성자 관리자 작성일 23-03-18 22:11 조회 405 댓글 0

본문

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");

}

}


}


추천0

댓글목록 0

등록된 댓글이 없습니다.


Copyright © dancePKT. All rights reserved.
PC 버전으로 보기