<file_sep>package model;

public class UserBeans {

private int id;
private String loginId;
private String name;
private String birthDate;
private String password;
private String createDate;
private String updateDate;

public UserBeans(String loginId, String name) {
	this.loginId = loginId;
	this.name = name;

}
public UserBeans(int id) {
	this.id = id;
}
public UserBeans (int id, String loginId, String name,String birthDate, String password, String createDate,
		String updateDate) {
	this.id = id;
	this.loginId = loginId;
	this.name = name;
	this.birthDate = birthDate;
	this.password = <PASSWORD>;
	this.createDate = createDate;
	this.updateDate = updateDate;

}
public UserBeans (String password,String name,String birthDate) {
	this.password = <PASSWORD>;
	this.name = name;
	this.birthDate = birthDate;
}

public UserBeans (String loginId, String name,String birthDate, String password) {
	this.loginId = loginId;
	this.name = name;
	this.birthDate = birthDate;
	this.password = <PASSWORD>;


}




public int getId() {
	return id;
}
public void setId(int id) {
	this.id = id;
}
public String getLoginId() {
	return loginId;
}
public void setLoginId(String loginId) {
	this.loginId = loginId;
}
public String getName() {
	return name;
}
public void setName(String name) {
	this.name = name;
}
public String getBirthDate() {
	return birthDate;
}
public void setBirthDate(String birthDate) {
	this.birthDate = birthDate;
}
public String getPassword() {
	return password;
}
public void setPassword(String password) {
	this.password = <PASSWORD>;
}
public String getCreateDate() {
	return createDate;
}
public void setCreateDate(String createDate) {
	this.createDate = createDate;
}
public String getUpdateDate() {
	return updateDate;
}
public void setUpdateDate(String updateDate) {
	this.updateDate = updateDate;
}
}

<file_sep>package controller;

import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.sql.SQLException;
import java.util.List;

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 javax.xml.bind.DatatypeConverter;

import dao.UserDao;
import model.UserBeans;

/**
 * Servlet implementation class NewUsersServlet
 */
@WebServlet("/NewUsersServlet")
public class NewUsersServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public NewUsersServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		String id = request.getParameter("id");
		UserDao infoDao = new UserDao();
		UserBeans user = infoDao.UserInfo(id);
		request.setAttribute("user", user);

		RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/jsp/NewUser.jsp");
		dispatcher.forward(request, response );

		}






	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		UserDao loginDao = new UserDao();
			List<UserBeans> userList =loginDao.findAll();



		String loginId = request.getParameter("loginId");
		String password = request.getParameter("password");
		String re_password = request.getParameter("re_password");
		String name = request.getParameter("name");
		String birthDate = request.getParameter("birth_date");
		UserDao infoDao = new UserDao();
		UserBeans user = infoDao.LoginInfo(loginId, password);

		Charset charset = StandardCharsets.UTF_8;

		String algorithm = "MD5";


		byte[] bytes = null;
		try {
			bytes = MessageDigest.getInstance(algorithm).digest(password.getBytes(charset));
		} catch (NoSuchAlgorithmException e) {

			e.printStackTrace();
		}
		String result = DatatypeConverter.printHexBinary(bytes);


        if (!password.equals(re_password )|| loginId == "" || name == "" || birthDate == "" || password == ""
        		) {
			request.setAttribute("errMsg","入力された内容は正しくありません。");

			UserBeans ub = new UserBeans(loginId,name,birthDate,password);
			request.setAttribute("ub", ub);

			RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/jsp/NewUser.jsp");
			dispatcher.forward(request, response);
			return ;
		}
        UserDao NewUserDao = new UserDao();
        try {
        	NewUserDao.NewUser(loginId, name, birthDate, result);
        } catch (SQLException e) {
        	request.setAttribute("errmSg", "そのログインIDは既に使用されています。");
        	RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/jsp/NewUser.jsp");
    		dispatcher.forward(request, response);
    		return;
        }

		String passwordP = <PASSWORD>;
		String id = request.getParameter("id");
		response.sendRedirect("LoginListServlet");





	}

}
<file_sep>package controller;

import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

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 javax.xml.bind.DatatypeConverter;

import dao.UserDao;
import model.UserBeans;

/**
 * Servlet implementation class UsersUpdateServlet
 */
@WebServlet("/UsersUpdateServlet")
public class UsersUpdateServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public UsersUpdateServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
		request.setCharacterEncoding("UTF-8");
		String id = request.getParameter("id");
		UserDao infoDao = new UserDao();
		UserBeans user = infoDao.UserInfo(id);
		request.setAttribute("user", user);
		RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/jsp/UsersUpdate.jsp");
		dispatcher.forward(request, response );
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		String password = request.getParameter("password");
		String re_password = request.getParameter("re_password");
		String name = request.getParameter("name");
		String birthDate = request.getParameter("birthDate");
		String id = request.getParameter("id");
		String loginId = request.getParameter("loginId");

		Charset charset = StandardCharsets.UTF_8;

		String algorithm = "MD5";


		byte[] bytes = null;
		try {
			bytes = MessageDigest.getInstance(algorithm).digest(password.getBytes(charset));
		} catch (NoSuchAlgorithmException e) {

			e.printStackTrace();
		}
		String result = DatatypeConverter.printHexBinary(bytes);


		if(!password.equals(re_password)|| name == "" || birthDate == ""){
			request.setAttribute("errMsg","入力された内容は正しくありません。" );

			UserBeans ub = new UserBeans(loginId,name,birthDate,password);

			request.setAttribute("user", ub);


			RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/jsp/UsersUpdate.jsp");
			dispatcher.forward(request,response );

			return;

		}

		UserDao userUpdateDao = new UserDao();
		userUpdateDao.UsersUpdate(name, result, birthDate, id);

		response.sendRedirect("LoginListServlet");




	}

}
