package userverify;
import java.io.IOException;
import java.io.PrintWriter;
import java.security.Timestamp;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class FrontCon
*/
@WebServlet("*.do")
public class FrontCon extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public FrontCon() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("Served at: ").append(request.getContextPath());
actionDo(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
actionDo(request, response);
}
private void actionDo(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("actionDo()");
String uri = request.getRequestURI();
String conPath = request.getContextPath();
String command = uri.substring(conPath.length());
if(command.equals("/membersAll.do")) {
response.setContentType("text/html;charset=EUC-KR");
PrintWriter writer = response.getWriter();
writer.println("<html><head></head><body>");
Service service = new MembersAllService();
ArrayList<MemberDto> dtos = service.execute(request,response);
for(int i = 0; i< dtos.size(); i++) {
MemberDto dto = dtos.get(i);
String id = dto.getId();
String pw = dto.getPw();
String name = dto.getName();
String eMail = dto.geteMail();
java.sql.Timestamp rDate = dto.getrDate();
String address = dto.getAddress();
writer.println(id + "," + pw + ", " + name + ", " + eMail + ", " + rDate + ", " + address + "<hr/>");
}
writer.println("</body></head>");
}
}
}