admin/member/Modify.java > MODEL2

본문 바로가기

사이트 내 전체검색

뒤로가기 MODEL2

admin/member/Modify.java

페이지 정보

작성자 관리자 작성일 23-03-18 22:13 조회 454 댓글 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.AdminMemberDAO;

import model.Member;


@WebServlet("/admin/member/modify")

public class Modify extends HttpServlet {

private static final long serialVersionUID = 1L;


    public Modify() {

        super();

    }


protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

String id = request.getParameter("id");

AdminMemberDAO dao = new AdminMemberDAO();

Member member = dao.oneMember(id);

request.setAttribute("m", member);

RequestDispatcher dis = request.getRequestDispatcher("modify.jsp");

dis.forward(request, response);

}


protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

request.setCharacterEncoding("utf-8");

Member m = new Member();


m.setId(request.getParameter("mb_id"));

m.setPass(request.getParameter("mb_pass"));

m.setName(request.getParameter("mb_name"));

m.setAge(Integer.parseInt(request.getParameter("mb_age")));

m.setGender(request.getParameter("mb_gender"));

m.setEmail(request.getParameter("mb_email"));

m.setMemo(request.getParameter("mb_memo"));

AdminMemberDAO dao = new AdminMemberDAO();

dao.updateMember(m);

response.setContentType("text/html; charset=utf-8");

PrintWriter out = response.getWriter();


out.print("<script>");

out.print("opener.location.reload();"); //부모창 새로고침

out.print("self.close();"); //자식창 닫기

out.print("</script>");

}


}


추천0

댓글목록 0

등록된 댓글이 없습니다.


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